File: step.c

package info (click to toggle)
bombardier 0.8.2.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 172 kB
  • ctags: 74
  • sloc: ansic: 796; makefile: 60; sh: 39; perl: 33
file content (42 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
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
#include "bombardier.h"

void step_state_plane(struct struc_state * state)
{
    if (HEIGHT-1-((int)(state->x+2)/WIDTH)-state->houses[(state->x+2)%WIDTH]==state->line)
	state->crashed=1;
    else
    {
	state->x++;
	if ((state->x<WIDTH-3) && (state->blocks==0) && (state->line<HEIGHT-2) && (state->x%3==0))
    	    state->line++;
	if ((state->line==(HEIGHT-1)) && (state->x==(WIDTH-3)))
    	    state->x=WIDTH;
    }
}

void step_state_bomb(struct struc_state * state, struct struc_texts *texts)
{
    if (state->willbebombed)
    {
	state->bomby++;
	if (state->bomby>HEIGHT-2)
	    state->willbebombed=0;
	else if ((HEIGHT-1)-state->houses[state->bombx]==state->bomby)
        {
            if (state->houses_text[state->bombx]==-1)
	        state->houses_text[state->bombx]=seltext(state->houses_text, texts, state->houses[state->bombx]);
	    if (!state->text)
	    {
	        free(state->text);
	        state->text=NULL;
	    }
	    if (state->houses_text[state->bombx]!=-1)
    		asprintf(&(state->text),texts[state->houses_text[state->bombx]].text);
    	    state->houses[state->bombx]--;
	    state->blocks--;
    	    state->willbebombed--;
	    if (state->willbebombed==0) state->houses_text[state->bombx]=-1;
    	    state->score++;
    	}
    }
}