Fixed oversights in collision code. More sound control.
[luagame.git] / doc / class_object.txt
blob9453672481d20633409f26f4d66a1f2253fce4f0
1 = Object Class Reference =
3 == Attributes ==
4 _Italics_ means private (in the sense that they shouldn't be set manually).
6 [grid="all"]
7 `------------`--------------------
8 Attribute     Description
9 ----------------------------------
10 x             x position (on screen)
11 y             y position (on screen)
12 w             width
13 h             height
14 x_offset      drawing offset
15 y_offset      drawing offset
16 angle         movement heading in degrees
17 speed         speed (in pixels/update)
18 image         image of the Object
19 rects         list of collision Rects
20 type          type of Object (for collision)
21 max_updates   maximum number of updates before Object self collects
22 _num_updates_ current number of updates
23 _death_anim_  flag for if Object is in death animation (affects collision)
24 _collect_     flag to indicate if an Object should be collected
25 ----------------------------------
27 == Methods == 
28 [grid="all"]
29 `----------------------`--------------------
30 Method                  Description
31 --------------------------------------------
32 new(o)                  constructor
33 update()                updates the Object's state
34 draw()                  draws the Object's image at (x, y)
35 collide(ids, object)    method executed upon collision (undefined for base class)
36 get_center()            returns the center coordinates of the Object
37 set_origin()            sets the drawing offset (sprite is offset by these amounts to the upper left)
38 --------------------------------------------
40 == Usage ==
41 This class is not designed to be instantiated directly, instead it should be
42 extended and serve as the base for all in-game objects.
43 An example object definition is as follows:
45 [lua]
46 source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47 MyObj = Object:new()
48 MyObj.attr1 = 4
49 MyObj.attr2 = "some value"
51 --constructor
52 function MyObj:new(o)
53   o = o or {}\r
54   setmetatable(o, self)\r
55   self.__index = self\r
56   return o
57 end
59 --other methods defined here
60 source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~