New collision code! Minor doc changes.
[luagame.git] / demos / collision_test / scripts / code.lua
blob6ab16ce6efff55b8f128b769fe8cb4e85ffdf975
1 --[[
2 This is a template for livecoding.
4 It is required() by the main.lua.
6 One wants to code the global_update(), global_draw(), and global_collide() routines
7 Put any new variables after the "declare variables here" line
8 --]]
11 --Set the FPS here (game speed depends on this)
12 target_fps = 30
14 --declare variables here
15 red = Object:new()
16 red.image, red.h, red.w = get_image("images/red_rectangle.png")
17 red.collide = function(self)
18 print(os.time().." collision!")
19 end
21 blue = Object:new()
22 blue.image, blue.h, blue.w = get_image("images/blue_rectangle.png")
23 blue.x = 100
24 blue.y = 100
25 blue.angular_velocity = 1
27 --set up the events here: evman variable
28 evman.mouse.motion = function(x,y) red.x = x red.y = y end
29 evman.mouse.pressed[1] = function() red.angular_velocity = 1 end
30 evman.mouse.released[1] = function() red.angular_velocity = 0 end
32 --updating stuff goes here
33 function global_update()
34 red:update()
35 blue:update()
36 end
39 --drawing stuff goes here
40 function global_draw()
41 fill_screen(0,0,0)
42 blue:draw()
43 red:draw()
44 end
47 --collision stuff goes here
48 function global_collide()
49 check_collisions_obj_obj(red, blue)
50 end