File: cup.c

package info (click to toggle)
asciijump 1.0.2~beta-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 880 kB
  • sloc: ansic: 4,665; sh: 2,582; makefile: 190
file content (56 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* :: asciijump (client), gnu gpl v 2
   :: copyright (c) grzegorz moskal, g.moskal@opengruop.org */

#define CUP_C
#include "cup.h"

struct s_skier *cup_sk_head, *cup_sk_tail;
struct s_skier **cup_sk_array;
// index for skiers array
int cup_sk_no;
// current size for skiers array
int cup_sk_counter;
// max size for skiers array
int cup_sk_limit = 8;

// hills array,
struct s_hill **cup_hl_array;
// current size for skiers array
int cup_hl_counter;

int cup_hl_no;

void cup_show()
{
	state = A_cup;
}

void cup(int key)
{
	int i = 0;
	
	if (cup_sk_no == cup_sk_counter) {
		rs_scr_reinit(cup_sk_array, cup_sk_counter, HILL);
		cup_sk_no = 0;
		return;
	}
	// if this skier is controled by human and there is still some move on the screen
	// we have to wait for the finish. (may he plays)
	if (JUMPER->level == 0 && sk_service(JUMPER, key)) {
		play(JUMPER);	
		return;
	}
	
	if (JUMPER->level != 0)
		sk_cpujump(JUMPER);
	
	// next one please ;)
	cup_sk_no++;
	// if he isn`t out of bond, and .. there is still some hill
	if (cup_sk_no >= cup_sk_counter && HILL) {
		cup_hl_no++;
		for (i = 0; i < cup_sk_counter; i++) 
			sk_flush(cup_sk_array[i], HILL);
		sk_array_sort();
	}
}