-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshot.c
98 lines (89 loc) · 2.15 KB
/
shot.c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* $Id: shot.c,v 1.2 2003/04/26 03:24:16 kenta Exp $
*
* Copyright 2002 Kenta Cho. All rights reserved.
*/
/**
* Handle players shots(in IKA_MODE and GW_MODE).
*
* @version $Revision: 1.2 $
*/
#include "SDL.h"
#include <stdlib.h>
#include <stdio.h>
#include "genmcr.h"
#include "screen.h"
#include "vector.h"
#include "degutil.h"
#include "ship.h"
#include "shot.h"
#include "attractmanager.h"
#include "boss_mtd.h"
Shot shot[SHOT_MAX];
void
initShots ()
{
int i;
for (i = 0; i < SHOT_MAX; i++) {
shot[i].cnt = -1;
}
}
static int shotIdx = SHOT_MAX;
#define SHOT_SPEED 4096
#define SHOT_HEIGHT_SPEED (SHOT_SPEED/FIELD_SCREEN_RATIO)
//#define SHOT_HEIGHT_SPEED_X 26844 // fixed point representation of ratio
void addShot(int x, int y, int ox, int oy, int color) {
int i, d, ds;
Shot *st;
for ( i=0 ; i<SHOT_MAX ; i++ ) {
shotIdx--; if ( shotIdx < 0 ) shotIdx = SHOT_MAX-1;
if ( shot[shotIdx].cnt < 0 ) break;
}
if ( i >= SHOT_MAX ) return;
st = &(shot[shotIdx]);
st->x = (float)x/FIELD_SCREEN_RATIO; st->y = -(float)y/FIELD_SCREEN_RATIO;
d = getDeg(-ox, oy); ds = getDistance(ox, oy);
st->mx = -(float)sctbl[d] *SHOT_SPEED/(FIELD_SCREEN_RATIO*256);
st->my = (float)sctbl[d+256]*SHOT_SPEED/(FIELD_SCREEN_RATIO*256);
st->d = (float)d*360/1024;
st->color = color;
st->cnt = ds/SHOT_SPEED;
st->width = 0.07;
st->height = 0.1;
}
void moveShots() {
int i;
Shot *st;
if ( mode != IKA_MODE && mode != GW_MODE ) return;
for ( i=0 ; i<SHOT_MAX ; i++ ) {
if ( shot[i].cnt < 0 ) continue;
st = &(shot[i]);
st->x += st->mx/2;
st->y += st->my/2;
st->height += SHOT_HEIGHT_SPEED/2;
st->cnt--;
if ( st->cnt < 0 ) {
switch ( mode ) {
case IKA_MODE:
damageBoss(64);
break;
case GW_MODE:
damageBoss(30);
break;
}
}
}
}
void drawShots() {
int i;
Shot *st;
if ( mode != IKA_MODE && mode != GW_MODE ) return;
for ( i=0 ; i<SHOT_MAX ; i++ ) {
//if ( shot[i].cnt < 0 ) continue;
//Changed by Albert because of weird crashes.
if ( shot[i].cnt >= 0 ) {
st = &(shot[i]);
drawShot(st->x, st->y, st->d, st->color, st->width, st->height);
}
}
}