fix/workaround: removed glitches with scaling and quads
[uboot.git] / main.lua
blobe5a790f11f656a3aa69457762b98f6e59a3927cd
1 require 'cam'
2 require 'map'
3 require 'entities'
4 require 'console'
5 require 'physics'
6 require 'sonar'
8 entities = {}
9 console = {}
10 cameras = {}
11 maps = {}
12 sonarbubbles = {}
14 function love.load()
15 game = true --false if a new map is generated TODO used?
16 debug = false
17 MAXFPS = 60 -- TODO used?
18 map_grid = {}
20 -- create map and physical world
21 Map:generateMap() --TODO maybe use a real map instance to avoid global vars like map_grid
22 physics_createWorld()
24 local noOfTiles = 3
25 local tilesPath = "gfx/tilebatch.png"
26 local realTileSize = 32
27 local miniMapWidth = 250
28 local miniMapHeight = 150
29 local displayBuffer = 1 -- We have to buffer one tile before and behind our viewpoint. TODO used?? kick..
30 -- Create map:
31 maps[1] = Map:new({matrix=map_grid,noOfTiles=noOfTiles,tilesPath=tilesPath,realTileSize=realTileSize,displayBuffer=displayBuffer})
32 physics_createWalls(maps[1])
33 -- create player
34 local startcoords = maps[1]:generateSpawnPoints(100,100) --TODO map size in vars
35 entities[1] = Ship:new({})
36 entities[1]:init(unpack(startcoords))
37 entities[1]:setSpeed(0) --TODO kick, and maybe kick setter to, not necessary
38 entities[1].density = entities[1].body:getY() --TODO kick
39 -- create sonar bubble that follows the ship
40 sonarbubbles[1] = Sonarbubble:new({size=100})
41 sonarbubbles[1]:followEntity(1)
42 -- Create main camera and mini map camera
43 cameras[1] = Cam:new({anchorX=1,anchorY=1,width=love.graphics.getWidth(),height=love.graphics.getHeight(),zoom=1,map=1})
44 cameras[1]:followEntity(1)
45 cameras[2] = Cam:new({anchorX=1,anchorY=1,width=miniMapWidth,height=miniMapHeight,zoom=10,map=1})
46 cameras[2]:followEntity(1)
47 -- cameras[2]:setPosition(1,1)
48 console = Console:new()
49 end
52 function love.update(dt)
53 physics_update(dt)
54 for i,c in ipairs(cameras) do
55 c:updatePosition()
56 end
57 sonar_update()
58 -- process_game_input()
59 end
61 function love.draw()
62 -- iterate over cameras
63 for index,cam in ipairs(cameras) do
64 cam:getPicture()
65 end
66 console:draw()
67 end
70 function love.keypressed(key, unicode)
71 if not console:input(key) then
72 Cam:input(key)
73 end
74 if key == "escape" then
75 love.event.quit()
76 end
77 end