Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tons of balance improvements, new controls, and bug fixes.

Planes' destroy function is now called when they're destroyed from a shockwave.
This fixes the number planes in play always incrementing.

Added controls for "w" and "up" spinning the snakes clockwise, and controls
for "s" and "down" spinning the snakes counter-clockwise.
  • Loading branch information...
commit 675ebbc790425ac840952b9cd402b4b3853d1972 1 parent 3406af9
Taylor Arnicar authored January 29, 2012
4  constants.lua
@@ -59,6 +59,10 @@ constants.ENEMY_COLORS = {"red", "green", "yellow", "blue"}
59 59
 -- allowed # of enemies in the game.
60 60
 constants.INCREASE_MAX_ENEMY_COUNT_CHANCE = 1;
61 61
 
  62
+-- Integer %. What chance is there when a plane is destroyed to decrease the
  63
+-- maximum allowed # of enemies in the game.
  64
+constants.DECREASE_MAX_ENEMY_COUNT_CHANCE = 50;
  65
+
62 66
 -- Integer %. What chance is there per game update to spawn a new enemy that
63 67
 -- is currently missing from the game.
64 68
 constants.SPAWN_ENEMY_CHANCE = 1;
1  entities/chain_wave.lua
@@ -23,6 +23,7 @@ function ChainWave:update(dt, planes, booms, awesomes, chainwaves)
23 23
          local distance = (self.position - plane_position):len()
24 24
          if distance < constants.PLANE_RADIUS + self.radius then
25 25
             -- Chain wave caught a plane!
  26
+            plane:destroy()
26 27
             table.remove(planes, i)
27 28
             table.insert(booms, Explosion(booms.image, plane_position, self.color))
28 29
             multiplier = multiplier + 1
4  entities/plane.lua
@@ -94,8 +94,8 @@ end
94 94
 
95 95
 function Plane:destroy()
96 96
    numPlanes = numPlanes - 1
97  
-   -- Give a 40% chance of decreasing the max # of planes the game should have
98  
-   if (math.random(1,100) < 40) then
  97
+   -- Give a chance of decreasing the max # of planes the game should have
  98
+   if (math.random(1,100) < constants.DECREASE_MAX_ENEMY_COUNT_CHANCE) then
99 99
       numPlanesToHave = numPlanesToHave -1
100 100
    end
101 101
    self.trail = nil
4  entities/player.lua
@@ -21,12 +21,12 @@ end)
21 21
 function Player:update(dt)
22 22
    self.time = self.time + dt
23 23
    self.moving = false
24  
-   if love.keyboard.isDown("a") then
  24
+   if (love.keyboard.isDown("a") or love.keyboard.isDown("left")) then
25 25
       self.theta = self.theta - self.SPIN_RATE * dt
26 26
       self.moving = true
27 27
       self.facing = 1
28 28
    end
29  
-   if love.keyboard.isDown("d") then
  29
+   if (love.keyboard.isDown("d") or love.keyboard.isDown("right")) then
30 30
       self.theta = self.theta + self.SPIN_RATE * dt
31 31
       self.moving = true
32 32
       self.facing = -1
29  entities/snake.lua
@@ -18,13 +18,16 @@ local Snake = Class(function(self, image)
18 18
 end)
19 19
 
20 20
 function Snake:update(dt)
21  
-   -- Replaced with mousewheel
22  
-   --if love.keyboard.isDown("left") then
23  
-   --   self:spinCCW(dt)
24  
-   --end
25  
-   --if love.keyboard.isDown("right") then
26  
-   --   self:spinCW(dt)
27  
-   --end
  21
+   -- Pressing "w" or "up" on the keyboard should spin the snake CW.
  22
+   -- Pressing "s" or "down" on the keyboard should spin the snake CCW.
  23
+   if (love.keyboard.isDown("w") or love.keyboard.isDown("up")) then
  24
+      -- Spin a fair bit slower than it normally would. 
  25
+      self:spinCW(0.55)
  26
+   end
  27
+   if (love.keyboard.isDown("s") or love.keyboard.isDown("down")) then
  28
+      -- Spin a fair bit slower than it normally would. 
  29
+      self:spinCCW(0.55)
  30
+   end
28 31
 end
29 32
 
30 33
 function Snake:draw(snakeHealth)
@@ -55,12 +58,12 @@ function Snake:draw(snakeHealth)
55 58
 
56 59
 end
57 60
 
58  
-function Snake:spinCW()
59  
-   self.rotation = (self.rotation + constants.SNAKE_SPIN_RATE)
  61
+function Snake:spinCW(multiplier)
  62
+   self.rotation = (self.rotation + constants.SNAKE_SPIN_RATE * multiplier)
60 63
 end
61 64
 
62  
-function Snake:spinCCW()
63  
-   self.rotation = (self.rotation - constants.SNAKE_SPIN_RATE)
  65
+function Snake:spinCCW(multiplier)
  66
+   self.rotation = (self.rotation - constants.SNAKE_SPIN_RATE * multiplier)
64 67
 end
65 68
 
66 69
 function Snake:getCurrentColor(playerRotation)
@@ -93,11 +96,11 @@ function Snake:getCurrentColor(playerRotation)
93 96
 end
94 97
 
95 98
 -- Replaced with other ones for mousewheel
96  
---function Snake:spinCW(dt)
  99
+--function Snake:spinCW()
97 100
 --   self.rotation = self.rotation + self.SPIN_RATE * dt
98 101
 --end
99 102
 --
100  
---function Snake:spinCCW(dt)
  103
+--function Snake:spinCCW()
101 104
 --   self.rotation = self.rotation - self.SPIN_RATE * dt
102 105
 --end
103 106
 
6  states/play.lua
@@ -287,10 +287,12 @@ end
287 287
 
288 288
 function play:mousepressed(x, y, button)
289 289
    if button == "wd" then
290  
-      snake:spinCW()
  290
+      -- Double the spin effect if it came from the mouse.
  291
+      snake:spinCW(1)
291 292
    end
292 293
    if button == "wu" then
293  
-      snake:spinCCW()
  294
+      -- Double the spin effect if it came from the mouse.
  295
+      snake:spinCCW(1)
294 296
    end
295 297
 
296 298
    if button == "l" then

0 notes on commit 675ebbc

Please sign in to comment.
Something went wrong with that request. Please try again.