source: golgotha/src/golg/objs/buster_rocket.cc

Last change on this file was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.7 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "g1_object.hh"
10#include "math/num_type.hh"
11#include "math/angle.hh"
12#include "math/trig.hh"
13#include "math/random.hh"
14#include "tile.hh"
15#include "saver.hh"
16#include "math/pi.hh"
17#include "map.hh"
18#include "map_man.hh"
19#include "object_definer.hh"
20#include "resources.hh"
21
22#include "objs/buster_rocket.hh"
23#include "objs/map_piece.hh"
24#include "objs/smoke_trail.hh"
25#include "objs/stank.hh"
26#include "objs/particle_emitter.hh"
27#include "lisp/lisp.hh"
28#include "li_objref.hh"
29
30static li_symbol_ref li_particle_emitter("particle_emitter");
31static li_g1_ref_class_member smoke_trail("smoke_trail");
32
33enum { DATA_VERSION=2 };
34
35g1_object_definer<g1_buster_rocket_class>
36g1_buster_rocket_def("buster_rocket");
37
38g1_object_definer<g1_buster_rocket_class>
39g1_heavy_rocket_def("heavy_rocket");
40
41g1_object_definer<g1_buster_rocket_class>
42g1_vortex_def("vortex_missile");
43
44g1_object_definer<g1_buster_rocket_class>
45g1_nuke_def("nuke_missile");
46
47
48g1_buster_rocket_class::g1_buster_rocket_class(g1_object_type id,
49                                               g1_loader_class *fp)
50  : g1_guided_missile_class(id,fp)
51{
52}
53
54static r1_texture_ref smoke_ref("smoke_particle");
55
56void g1_buster_rocket_class::add_smoke()
57{
58  g1_particle_emitter_params p;
59  g1_particle_emitter_class *emitter;
60  p.defaults();
61  p.start_size=0.05;
62  p.grow_speed=0.01;
63  p.max_speed=0.02;
64  p.air_friction=0.80;
65  p.num_create_attempts_per_tick=1;
66  p.particle_lifetime=20;
67 
68  p.texture=smoke_ref.get();
69
70  emitter = (g1_particle_emitter_class *)
71    g1_create_object(g1_get_object_type(li_particle_emitter.get()));
72  emitter->setup(x,y,h, p);
73 
74  vars->set(smoke_trail, new li_g1_ref(emitter));
75}
76
77void g1_buster_rocket_class::update_smoke()
78{
79  li_class_context c(vars);
80
81  if (!smoke_trail())
82    return;
83
84  g1_particle_emitter_class *st=(g1_particle_emitter_class *) smoke_trail()->value();
85  if (st)
86    st->move(lx,ly,lh);
87}
88
89void g1_buster_rocket_class::delete_smoke()
90{
91  li_class_context c(vars);
92
93  if (!smoke_trail())
94    return;
95
96  g1_particle_emitter_class *st=(g1_particle_emitter_class *) smoke_trail()->value();
97  if (st)
98  {
99    st->unoccupy_location();
100    st->request_remove();
101    vars->set(smoke_trail, li_g1_null_ref());
102  }
103}
104
105
Note: See TracBrowser for help on using the repository browser.