First commit of LuaGame with an OpenGL backend.
[luagame.git] / demos / luashooter / scripts / backgrounds.lua
blob6e4b7678c0d905d55b3203f72d0c93d1b3d8a236
1 --[[
2 File: backgrounds.lua
3 Author: Brett Lajzer
4 Date: 5.25.2006
6 About:
7 This file contains various functions that draw backgrounds.
8 --]]
10 backgrounds = {}
12 --background images
13 backgrounds.star_bg = get_image("img/star_bg.bmp")
16 --background variables
17 backgrounds.offset = 0
20 --background-drawing functions
22 function backgrounds.stars_fixed()
24 local wide = math.ceil(s_width/128)
25 local tall = math.ceil(s_height/128)
27 for i = 0, wide do
28 for j = 0, tall do
29 display(backgrounds.star_bg, 128 * i, 128 *j,0,1,1)
30 end
31 end
33 end
36 function backgrounds.stars_scrolling(speed)
38 local wide = math.ceil(s_width/128)
39 local tall = math.ceil(s_height/128)
41 for i = 0, wide do
42 for j = -1, tall do
43 display(backgrounds.star_bg, 128 * i, 128 *j + backgrounds.offset,0,1,1)
44 end
45 end
46 backgrounds.offset = backgrounds.offset + (speed or 4)
47 if backgrounds.offset >= 128 then backgrounds.offset = 0 end
48 end