Fixed some little errors with the drawing functions.
[luagame.git] / doc / class_object.txt
blob2fa79551faf4626a4ad9e6e5edbdcab228b41d3a
1 = Object Class Reference =
3 == Attributes ==
4 [grid="all"]
5 `---------------`--------------------
6 Attribute        Description
7 -------------------------------------
8 x                x position (on screen)
9 y                y position (on screen)
10 w                width
11 h                height
12 x_offset         drawing offset
13 y_offset         drawing offset
14 heading          movement heading in degrees
15 speed            speed (in pixels/update)
16 rotation         current rotation of the object
17 angular_velocity angular velocity of the object
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 no_collide       flag for if Object should not be colliding
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 Object 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 unload()                unloads any resources used and sets class to nil (undefined for Object class)
39 --------------------------------------------
41 == Usage ==
42 This class is not designed to be instantiated directly, instead it should be
43 extended and serve as the base for all in-game objects.
44 An example object definition is as follows:
46 [lua]
47 source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48 MyObj = Object:new()
49 MyObj.attr1 = 4
50 MyObj.attr2 = "some value"
52 --constructor
53 function MyObj:new(o)
54   o = o or {}\r
55   setmetatable(o, self)\r
56   self.__index = self\r
57   return o
58 end
60 --other methods defined here
61 source~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~