Subversion Repositories Games.Rick Dangerous

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * src/e_bullet.c
3
 *
4
 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
5
 *
6
 * The use and distribution terms for this software are contained in the file
7
 * named README, which can be found in the root of this distribution. By
8
 * using this software in any fashion, you are agreeing to be bound by the
9
 * terms of this license.
10
 *
11
 * You must not remove this notice, or any other, from this software.
12
 */
13
 
14
#include "system.h"
15
#include "game.h"
16
#include "ents.h"
17
#include "e_bullet.h"
18
 
19
#include "maps.h"
20
 
21
 
22
/*
23
 * public vars (for performance reasons)
24
 */
25
S8 e_bullet_offsx;
26
S16 e_bullet_xc, e_bullet_yc;
27
 
28
 
29
/*
30
 * Initialize bullet
31
 */
32
void e_bullet_init (U16 x, U16 y)
33
{
34
   E_BULLET_ENT.n = 0x02;
35
   E_BULLET_ENT.x = x;
36
   E_BULLET_ENT.y = y + 0x0006;
37
 
38
   if (game_dir == LEFT)
39
   {
40
      e_bullet_offsx = -0x08;
41
      E_BULLET_ENT.sprite = 0x21;
42
   }
43
   else
44
   {
45
      e_bullet_offsx = 0x08;
46
      E_BULLET_ENT.sprite = 0x20;
47
   }
48
 
49
   syssnd_play (WAV_BULLET, 1);
50
}
51
 
52
 
53
/*
54
 * Entity action
55
 *
56
 * ASM 1883, 0F97
57
 */
58
void e_bullet_action (U8 e)
59
{
60
   /* move bullet */
61
   E_BULLET_ENT.x += e_bullet_offsx;
62
 
63
   if (E_BULLET_ENT.x <= 0x01 || E_BULLET_ENT.x > 0xe8)
64
      E_BULLET_ENT.n = 0; // out: deactivate
65
   else
66
   {
67
      /* update bullet center coordinates */
68
      e_bullet_xc = E_BULLET_ENT.x + 0x0c;
69
      e_bullet_yc = E_BULLET_ENT.y + 0x05;
70
 
71
      if (map_eflg[map_map[e_bullet_yc >> 3][e_bullet_xc >> 3]] & MAP_EFLG_SOLID)
72
         E_BULLET_ENT.n = 0; // hit something: deactivate
73
   }
74
}