Commits

Anonymous committed 1809cf6

- Fixed comments
- Added level text on lower right part of the screen
- Changed "grab" display to show available movement instead of a square.

  • Participants
  • Parent commits ead1e3f

Comments (0)

Files changed (2)

 function love.load()
     _level = 1
     _countdownToNext = -1
+    _isDisplayingLevelText = true
+    _levelFont = love.graphics.newFont( 30 )
+    _directionsFont = love.graphics.newFont( 20 )
     
     love.graphics.setBackgroundColor( 120, 120, 120 )
     
 end
 
 function loadLevel( num )
+    -- Cheap and easy way...
+    -- no need to keep track of the # of levels, as long as they're sequential
     local filename = "levels/" .. num .. ".png"
     if ( love.filesystem.isFile( filename ) ) then
+        _isDisplayingLevelText = true
         map:loadMap( filename )
         local posX, posY = map:getPlayerPos()
         pl:releaseGrab()
     else
         --A WINNER IS YOU!
         --temporary win condition
+        _isDisplayingLevelText = false
         map:loadMap( "levels/win.png" )
         local posX, posY = map:getPlayerPos()
         pl:releaseGrab()
 end
 
 function love.draw()
-    love.graphics.setColor(255,0,0)
-    love.graphics.print("This text is red", 100, 200)
-    
     love.graphics.setColor( 245, 245, 245 )
     love.graphics.rectangle( "fill", 15, 15, 750, 510 );
     
     map:draw()
     pl:draw()
     
+    if ( _isDisplayingLevelText ) then 
+        love.graphics.setColor( 255, 255, 255)
+        love.graphics.setFont( _levelFont )
+        love.graphics.print( _level, 850, 434, 0)
+    end
 end
 
 -- dt = delta time
         love.event.push( "quit" )
     end
     
-    if ( key == "r" ) then      --Spacebar
+    if ( key == "r" ) then      --R key
         loadLevel( _level )
     end
     

objects/player.lua

         
         love.graphics.setColor( color.r, color.g, color.b )
         love.graphics.rectangle( "fill", screenPosX, screenPosY, size, size )
-        if ( bIsGrabbing ) then
-            love.graphics.setColor( 255,  255, 255 )
-            love.graphics.rectangle( "fill", 
-                                    ( self.gridPosition.x * size ) - ( size / 4), 
-                                    ( self.gridPosition.y * size ) - ( size / 4 ), 
-                                    size / 2, size  /2 )
+        
+        --Display triangles to show which moves the player can make
+        love.graphics.setColor( 255,  255, 255 )
+        local x = self.gridPosition.x * size
+        local y = self.gridPosition.y * size
+        local quarter = ( size / 4 )        
+        local tHeight = size / 2
+        if ( not grabbed.up ) then
+            love.graphics.triangle( "fill", 
+                                    x - quarter, y - quarter, 
+                                    x, y - tHeight, 
+                                    x + quarter, y - quarter )
+        end
+        if ( not grabbed.down ) then
+            love.graphics.triangle( "fill", 
+                                    x - quarter, y + quarter, 
+                                    x, y + tHeight, 
+                                    x + quarter, y + quarter )
+        end
+        if ( not grabbed.left ) then
+            love.graphics.triangle( "fill", 
+                                    x - quarter, y - quarter, 
+                                    x - tHeight, y, 
+                                    x - quarter, y + quarter )
+        end
+        if ( not grabbed.right ) then
+            love.graphics.triangle( "fill", 
+                                    x + quarter, y - quarter, 
+                                    x + tHeight, y, 
+                                    x + quarter, y + quarter )
         end
     end