summaryrefslogtreecommitdiff
path: root/apps/plugins/xrick/e_bullet.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/xrick/e_bullet.c')
-rw-r--r--apps/plugins/xrick/e_bullet.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/apps/plugins/xrick/e_bullet.c b/apps/plugins/xrick/e_bullet.c
new file mode 100644
index 0000000000..86542256e8
--- /dev/null
+++ b/apps/plugins/xrick/e_bullet.c
@@ -0,0 +1,84 @@
1/*
2 * xrick/e_bullet.c
3 *
4 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net).
5 * Copyright (C) 2008-2014 Pierluigi Vicinanza.
6 * All rights reserved.
7 *
8 * The use and distribution terms for this software are contained in the file
9 * named README, which can be found in the root of this distribution. By
10 * using this software in any fashion, you are agreeing to be bound by the
11 * terms of this license.
12 *
13 * You must not remove this notice, or any other, from this software.
14 */
15
16#include "xrick/e_bullet.h"
17
18#include "xrick/system/system.h"
19#include "xrick/game.h"
20#include "xrick/ents.h"
21#include "xrick/maps.h"
22
23/*
24 * public vars (for performance reasons)
25 */
26S8 e_bullet_offsx;
27S16 e_bullet_xc, e_bullet_yc;
28
29/*
30 * Initialize bullet
31 */
32void
33e_bullet_init(U16 x, U16 y)
34{
35 E_BULLET_ENT.n = 0x02;
36 E_BULLET_ENT.x = x;
37 E_BULLET_ENT.y = y + 0x0006;
38 if (game_dir == LEFT) {
39 e_bullet_offsx = -0x08;
40 E_BULLET_ENT.sprite = 0x21;
41 }
42 else {
43 e_bullet_offsx = 0x08;
44 E_BULLET_ENT.sprite = 0x20;
45 }
46#ifdef ENABLE_SOUND
47 syssnd_play(soundBullet, 1);
48#endif
49}
50
51
52/*
53 * Entity action
54 *
55 * ASM 1883, 0F97
56 */
57void
58e_bullet_action(U8 e/*unused*/)
59{
60 (void)e;
61
62 /* move bullet */
63 E_BULLET_ENT.x += e_bullet_offsx;
64
65 if (E_BULLET_ENT.x <= -0x10 || E_BULLET_ENT.x > 0xe8)
66 {
67 /* out: deactivate */
68 E_BULLET_ENT.n = 0;
69 }
70 else
71 {
72 /* update bullet center coordinates */
73 e_bullet_xc = E_BULLET_ENT.x + 0x0c;
74 e_bullet_yc = E_BULLET_ENT.y + 0x05;
75 if (map_eflg[map_map[e_bullet_yc >> 3][e_bullet_xc >> 3]] & MAP_EFLG_SOLID)
76 {
77 /* hit something: deactivate */
78 E_BULLET_ENT.n = 0;
79 }
80 }
81}
82
83
84/* eof */