First commit of LuaGame with an OpenGL backend.
[luagame.git] / demos / collision_test / scripts / code.lua
blob1dc7f3fcc271446de1ee57b47d1eef06aa97c9fb
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 test.x = x test.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 test:update()
37 end
40 --drawing stuff goes here
41 function global_draw()
42 fill_screen(0,0,0)
43 blue:draw()
44 red:draw()
45 test:draw()
46 end
49 --collision stuff goes here
50 function global_collide()
51 check_collisions_obj_obj(red, blue)
52 end