Permalink
Browse files

Merge github.com:rit-sse/RapDevXI into better-umbrella-or-gun

  • Loading branch information...
2 parents 2112612 + 6284da6 commit 0c101a52bde416968b864d4fce54b2202a522fa0 @crhossen crhossen committed Mar 19, 2012
Showing with 912 additions and 18 deletions.
  1. BIN src/games/HackTheGibson/audio/voodoo.ogg
  2. BIN src/games/HackTheGibson/audio/voodoo_loop.ogg
  3. +305 −0 src/games/HackTheGibson/game.lua
  4. BIN src/games/HackTheGibson/icon-big.png
  5. BIN src/games/HackTheGibson/icon.png
  6. +73 −0 src/games/HackTheGibson/main.lua
  7. BIN src/games/HackTheGibson/textures/bullet.png
  8. BIN src/games/HackTheGibson/textures/enemy.png
  9. BIN src/games/HackTheGibson/textures/player.png
  10. BIN src/games/HackTheGibson/textures/tex1.png
  11. BIN src/games/HackTheGibson/textures/tex2.png
  12. BIN src/games/HackTheGibson/textures/tex3.png
  13. +29 −17 src/games/challenge of the ni/game.lua
  14. BIN src/games/do you like waffles/ant.png
  15. BIN src/games/do you like waffles/ant1.png
  16. BIN src/games/do you like waffles/ant2.png
  17. BIN src/games/do you like waffles/chomp.mp3
  18. BIN src/games/do you like waffles/frenchtoast.png
  19. +131 −0 src/games/do you like waffles/game.lua
  20. BIN src/games/do you like waffles/grass.png
  21. BIN src/games/do you like waffles/icon-big.png
  22. BIN src/games/do you like waffles/icon.png
  23. +73 −0 src/games/do you like waffles/main.lua
  24. BIN src/games/do you like waffles/pancake.png
  25. BIN src/games/do you like waffles/waffle.png
  26. BIN src/games/do you like waffles/waffles.mp3
  27. BIN src/games/the final sacrifice/city.png
  28. +224 −0 src/games/the final sacrifice/game.lua
  29. BIN src/games/the final sacrifice/icon-big.png
  30. BIN src/games/the final sacrifice/icon.png
  31. +73 −0 src/games/the final sacrifice/main.lua
  32. BIN src/games/the final sacrifice/rock.png
  33. BIN src/games/the final sacrifice/rowsdower.png
  34. BIN src/games/the final sacrifice/sound.mp3
  35. BIN src/games/the final sacrifice/thug.png
  36. BIN src/games/the final sacrifice/troy.png
  37. +4 −1 src/listOfGames.lua
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,305 @@
+return {
+ standalone_difficulty = "impossible",
+ --Here go all of the static info values for our game
+ -- Remember a comma after each entry, as we are in a table initialization
+
+ --Difficulties should be a list of difficulties this game can be.
+ --For Example:
+ -- If your game going to be a medium difficulty, and can't
+ -- be made easier or harder just make it {"medium"}
+
+ -- If your game can be made to be easy or impossible,
+ -- make it {"easy","impossible"}
+ difficulties = {"easy","medium","hard","impossible"},
+
+ --PR is how appropriate your game is. Valid values are:
+ -- "child" approprate to show at imagine RIT
+ -- "rit" approprate to show to other RIT students
+ -- "sse" approprate only to show to SSE members
+ -- "deans car" this game will be deleted out of the repository on Monday before anyone sees it who wasn't here
+ -- (grab your own local copy)
+ PR = "rit",
+
+ --Keys is an indication to the user that says where to put their hands.
+ --It needs to be a list with any values from:
+ -- {"arrows","wasd","full keyboard","mouse","space"}
+ keys = {"arrows"},
+
+ --The longest this game will EVER take. Note: by overriding the isDone method you can end
+ --the game sooner. This is just how long until the engine kills your game and asks it for
+ --a score by force.
+ maxDuration = 30,
+
+ --This is where you define what an actual running version of your game is.
+ --The first parameter is a table you must fill in with your desired callbacks,
+ --as well as any user data. Info is a table with key/values:
+ -- difficulty = a value from the difficulties list defined above. You should change at least some aspect
+ -- of how your game is initialized based on this difficulty.
+ --
+ -- player = some string naming the current player. Don't do anything with this but display it, if even that.
+
+ makeGameInstance = function(self, info)
+ --Each game may choose how to scale difficulty. The template imposes a time limit
+ --that is modified by the difficulty of the game
+ self.time_limit = ({easy=10, medium=15, hard=20, impossible=30})[info.difficulty]
+
+ --Callbacks
+
+ self.getReady = function(self, basePath)
+ --get ready is called during the splash screen.
+ --The intent is to load all sounds and images during getReady
+
+ --Concatenate basePath with any resource names. This makes your game work in both standalone
+ --and the main game mode
+
+ --DON'T START SOUNDS IN GET READY! They will begin playing during the splash screen, and
+ --be stopped before your game is actually shown
+
+ --self.image = love.graphics.newImage(basePath.."sprite.png")
+ --self.sound = love.sound.newSource(basePath.."sound.mp3")
+
+ -- Seed RNG
+ math.randomseed(os.time())
+
+ --Also set up your own initial game state here.
+ self.elapsed_time = 0
+ self.waitTime = 0
+ self.waitCap = ({easy=1.5, medium=1.0, hard=.5, impossible=.4})[info.difficulty]
+ self.score = 2
+
+ -- Player health and position/size values
+ self.player = {}
+ self.player.health = 3
+ self.player.x = 20
+ self.player.y = 200
+ self.player.width = 50
+ self.player.height = 61
+
+ -- Enemy position/size values
+ self.enemy = {}
+ self.enemy.x = 320
+ self.enemy.y = 200
+ self.enemy.width = 100
+ self.enemy.height = 116
+ self.enemy.bullets = {}
+
+ -- Bounding boxes
+ self.playerBoundingBox = {}
+ self.playerBoundingBox.left = 0
+ self.playerBoundingBox.right = 200
+ self.playerBoundingBox.top = 0
+ self.playerBoundingBox.bottom = 400
+
+ self.enemyBoundingBox = {}
+ self.enemyBoundingBox.left = 200
+ self.enemyBoundingBox.right = 400
+ self.enemyBoundingBox.top = 0
+ self.enemyBoundingBox.bottom = 400
+
+ -- Set up the background texture data structures
+ self.backgroundTextures = {}
+ self.backgroundQueue = {}
+
+ self.makeBullet = function(self)
+ local b = {}
+ b.x = self.enemy.x
+ b.y = self.enemy.y + 20
+ b.width = 20
+ b.height = 13
+ table.insert(self.enemy.bullets, b)
+ end
+
+ self:getAudioReady( basePath.."audio/" )
+ self:getTexturesReady( basePath.."textures/" )
+
+ end
+
+ self.getAudioReady = function( self, audioPath )
+ --Looping audio
+ self.backgroundLoopStarted= false
+ self.backgroundLoop = love.audio.newSource( audioPath.."voodoo_loop.ogg" )
+ self.backgroundLoop:setLooping( true )
+ end
+
+ self.getTexturesReady = function( self, texturePath )
+ -- Background textures
+ i = 1
+
+ -- Loop through files of the form texn.png, where n is a number,
+ -- until no more are detected.
+ while love.filesystem.exists( texturePath.."tex"..i..".png" ) do
+ path = texturePath.."tex"..i..".png"
+ backgroundTexture = love.graphics.newImage( path )
+ table.insert( self.backgroundTextures, backgroundTexture )
+ i = i + 1
+ end
+
+ for i = 1, 3 do
+ self.backgroundQueue[i] = {}
+ self.backgroundQueue[i].image = self.backgroundTextures[i]
+ self.backgroundQueue[i].x = -400 + ( 400 * ( i - 1 ) )
+ end
+
+ -- Sprites
+ self.player.img = love.graphics.newImage( texturePath.."player.png" )
+ self.enemy.img = love.graphics.newImage( texturePath.."enemy.png" )
+ self.enemy.bulletImg = love.graphics.newImage( texturePath.."bullet.png")
+
+ end
+
+ self.update = function(self, dt)
+ --update is called in between draws. dt is the time in seconds since the last time
+
+ print("SCORE:"..self.score)
+
+ --here we just keep track of how much time has passed
+ self.elapsed_time = self.elapsed_time + dt
+ self.waitTime = self.waitTime + dt
+
+ -- Start playing background audio loop
+ if not self.backgroundLoopStarted then
+ love.audio.play( self.backgroundLoop )
+ self.backgroundLoopStarted = true
+ end
+
+ -- Move each background rectangle.
+ for i = 1, 3 do
+ speedMultiplier = 300
+ self.backgroundQueue[i].x = self.backgroundQueue[i].x - ( speedMultiplier * dt )
+
+ if self.backgroundQueue[i].x <= -400 then
+ self.backgroundQueue[i].x = self.backgroundQueue[i].x + 800
+
+ randomIndex = math.random( 1, #self.backgroundTextures )
+ self.backgroundQueue[i].image = self.backgroundTextures[randomIndex]
+ end
+ end
+
+ -- Move each bullet
+ for i = 1, #self.enemy.bullets do
+ print(self.enemy.bullets[i])
+ self.enemy.bullets[i].x = self.enemy.bullets[i].x - 300*dt
+ if self.enemy.bullets[i].x < -self.enemy.bullets[i].width then
+ local deleteTrue = i
+ else
+ cBullet = self.enemy.bullets[i]
+ if(cBullet.y > self.player.y and cBullet.y < self.player.y+self.player.height)
+ or(cBullet.y+cBullet.height > self.player.y and cBullet.y+cBullet.height < self.player.y+self.player.height) then
+ if cBullet.x > self.player.x and cBullet.x < self.player.x+self.player.width then
+ local deleteTrue = i
+ self.score = self.score -1
+ end
+ end
+ end
+ end
+ if deleteTrue then table.remove(self.enemy.bullets, deleteTrue) end
+
+ -- Handle player movement
+ playerSpeedMod = 200
+ self:handlePlayerInput( playerSpeedMod, dt )
+ self:handleEntityBounding( self.player, self.playerBoundingBox )
+
+ -- Handle AI Movement
+ aiSpeedMod = 100
+ self:handleAIThink( aiSpeedMod, dt )
+ self:handleEntityBounding( self.enemy, self.enemyBoundingBox )
+
+
+
+ end
+
+ self.handleAIThink = function( self, aiSpeedMod, dt )
+ if self.player.y > self.enemy.y then
+ self.enemy.y = self.enemy.y + aiSpeedMod * dt
+ end
+ if self.player.y < self.enemy.y then
+ self.enemy.y = self.enemy.y - aiSpeedMod * dt
+ end
+
+ -- Fire bullets
+ if self.waitTime > self.waitCap then
+ self.waitTime = 0
+ self:makeBullet()
+ end
+ end
+
+ self.handlePlayerInput = function( self, multi, dt )
+ if love.keyboard.isDown( "up" ) then
+ self.player.y = self.player.y - ( multi * dt )
+ end
+
+ if love.keyboard.isDown( "down" ) then
+ self.player.y = self.player.y + ( multi * dt )
+ end
+
+ if love.keyboard.isDown( "left" ) then
+ self.player.x = self.player.x - ( multi * dt )
+ end
+
+ if love.keyboard.isDown( "right" ) then
+ self.player.x = self.player.x + ( multi * dt )
+ end
+ end
+
+ self.handleEntityBounding = function( self, entity, boundingBox )
+ if entity.x < boundingBox.left then
+ entity.x = boundingBox.left
+ end
+
+ if entity.x + entity.width > boundingBox.right then
+ entity.x = boundingBox.right - entity.width
+ end
+
+ if entity.y < boundingBox.top then
+ entity.y = boundingBox.top
+ end
+
+ if entity.y + entity.height > boundingBox.bottom then
+ entity.y = boundingBox.bottom - entity.height
+ end
+ end
+
+ self.draw = function(self)
+ -- Draw the pretty scrolly background thing
+ for i = 1, 3 do
+ if self.backgroundQueue[i].x > -400 and self.backgroundQueue[i].x < 400 then
+ love.graphics.draw(self.backgroundQueue[i].image, self.backgroundQueue[i].x, 0)
+ end
+ end
+
+ --here we just put how much time is left in the upper left corner
+ -- look at https://love2d.org/wiki/love.graphics for fun drawing stuff
+ love.graphics.print( (self.time_limit-self.elapsed_time).."s left", 0,0)
+
+ -- Draw the player and the enemy
+ love.graphics.setColorMode('replace')
+ love.graphics.draw(self.player.img, self.player.x, self.player.y)
+ love.graphics.draw(self.enemy.img, self.enemy.x, self.enemy.y)
+
+ -- Draw the bullets?
+ for i=1,#self.enemy.bullets do
+ love.graphics.draw(self.enemy.bulletImg, self.enemy.bullets[i].x, self.enemy.bullets[i].y)
+ end
+ end
+
+ self.isDone = function(self)
+ --This can return true to have the game end sooner that the time_limit
+ --set for the type of game.
+
+ --we are done when we are out of time.
+ --return self.elapsed_time > self.time_limit
+ return self.score < 0
+ end
+
+ self.getScore = function(self)
+ --return a number -1 to 1. anything >0 is a "passing" score
+ return self.score
+ end
+
+ self.keypressed = function(self, key)
+ end
+
+ self.keyreleased = function(self, key)
+ end
+ end
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,73 @@
+--This file make a game run as a standalone game
+--local HC = require 'hardoncollider' --if your game needs HC in standalone, copy the directory into your path and uncomment this. Don't comit that copy though
+
+local game = {
+ getReady = function(self,basePath) end,
+ update = function(self, dt) end,
+ draw = function(self) end,
+ keypressed = function(self, key) end,
+ keyreleased = function(self, key) end,
+ mousepressed = function(self, x, y, button) end,
+ mousereleased = function(self, x, y, button) end,
+ getScore = function(self) return -1 end,
+ isDone = function(self) return false end
+}
+
+local gameClass = require('game.lua')
+local difficulty = gameClass.standalone_difficulty
+if difficulty == 0 then difficulty = gameClass.difficulties[1] end
+gameClass.makeGameInstance(game,{difficulty=difficulty, player="player1"})
+
+function love.load()
+ love.graphics.setMode(400,400,false,true,0)
+
+end
+
+local ready = false
+local elapsed = 0
+function love.update(dt)
+ if not ready then
+ ready = true
+ game:getReady("")
+ else
+ if not (game:isDone() or elapsed> gameClass.maxDuration) then
+ elapsed = elapsed+dt
+ game:update(dt)
+ end
+ end
+end
+
+function love.draw()
+ if (game:isDone() or elapsed> gameClass.maxDuration) then
+ love.graphics.setColor(255,255,255)
+ love.graphics.print("Score was: "..game:getScore(),10,10)
+ else
+ love.graphics.setColor(255,255,255)
+ game:draw()
+ end
+
+
+end
+
+function love.keypressed(key)
+ game:keypressed(key)
+ if key == "escape" then
+ love.event.push('q')
+ end
+end
+
+function love.keyreleased(key)
+ game:keyreleased(key)
+end
+
+function love.mousepressed(x, y, button)
+ game:mousepressed(x, y, button)
+end
+
+function love.mousereleased(x, y, button)
+ game:mousereleased(x, y, button)
+end
+
+function on_collision(self, dt, shape_a, shape_b, mtv_x, mtv_y)
+ game:on_collision(self, dt, shape_a, shape_b, mtv_x, mtv_y)
+end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.

0 comments on commit 0c101a5

Please sign in to comment.