Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- What does not work?
- --Hitting, removes enemy without cammand
- --Spawning, see what you can do about that.
- --Make art
- --Find sounds
- --(optional) If Gameover Press key to restart.
- --Remake the map
- Debug.Log ("Good Luck")
- Level.Load ("Game.tmx")
- player = {
- object = nil,
- music = nil,
- health = 40,
- score = 0,
- beenBitten = false,
- beenHit = false,
- canFire = true,
- obstacle1 = nil,
- obstacle2 = nil,
- obstacle3 = nil,
- obstacle4 = nil,
- keys = 0,
- gate = nil,
- pause = false,
- items = 0,
- }
- enemies= {
- objects = nil,
- health = 2
- }
- sounds = {
- music = Sound.Load ( "music.mp3", true, true ),
- bump = Sound.Load ( "bump.wav", false, false ),
- shoot = Sound.Load ( "byte.wav", false, false ),
- reload = Sound.Load ( "alert.wav", false, false ),
- dying = Sound.Load ( "WilhelmScream.wav", false, false),
- }
- function Start ()
- --Sound.Play ( sounds.music )
- player.object = Level.GetObject ( "Player" )
- player.keys = Level.GetObject ( "Key1" )
- player.keys = Level.GetObject ( "Key2" )
- player.keys = Level.GetObject ( "Key3" )
- player.keys = Level.GetObject ( "Key4" )
- player.keys = Level.GetObject ( "Key5" )
- player.keys = Level.GetObject ( "Key6" )
- obstacles1 = Level.GetObjects ( "Obstacle1" )
- obstacles2 = Level.GetObjects ( "Obstacle2" )
- obstacles3 = Level.GetObjects ( "Obstacle3" )
- obstacles4 = Level.GetObjects ( "Obstacle4" )
- gates = Level.GetObjects ( "Gate" )
- Hud.Message ( "Run!!\n\nYou're Being Hunted!", 4 )
- Timer.Start ( "SpawnEnemy",5 , false )
- end
- function Update ()
- if not player.pause then
- DoPlayer ()
- DoEnemy ()
- DoHud ()
- DoCamera ()
- DoFiring ()
- DoGate ()
- end
- end
- function DoGate ()
- if player.items == 6 then
- for i = 1, #gates do -- Do not completely understand this part.
- gate = gates [ i ]
- Level.RemoveObject ( gate )
- end
- end
- end
- function DoPlayer ()
- move = Controller.Wasd (player.object, 5)
- if not move then
- if not Sound.IsPlaying ( playingBump ) then
- playingBump = Sound.Play ( sounds.bump )
- end
- end
- end
- function DoEnemy ()
- enemies.objects = Level.GetObjects ( "Enemy" )
- for i = 1, #enemies.objects do
- enemy = enemies.objects [ i ]
- move = Controller.Chase ( enemy, player.object, 1 )
- end
- end
- function DoHud ()
- Hud.Score ( "Dollars: "..player.score )
- Hud.Health ( "Health: "..player.health )
- end
- function DoCamera ()
- Camera.Follow ( player.object )
- end
- function DoFiring ()
- if Input.GetKey ( 32 ) and player.canFire then
- Level.Fire ( player.object, "Bullet", 50, "Hit" )
- player.canFire = false
- Timer.Start ("canFireAgain" , 1, false)
- playingShoot = Sound.Play ( sounds.shoot )
- playingReload = Sound.Play ( sounds.reload )
- end
- bullets = Level.GetObjects ( "Bullet" )
- for i = 1, #bullets do -- Do not completely understand this part.
- bullet = bullets [ i ]
- moved = Object.Forward ( bullet, 8 )
- if not moved then
- Level.RemoveObject ( bullet )
- end
- end
- end
- --Triggers
- function Hit ( target, source )
- name = Object.GetName ( target )
- if name == "Enemy" then
- --if target == enemy and player.beenHit == false then
- Debug.Log ("HIT")
- enemies.health = enemies.health - 1
- Timer.Start ( "HitAgain", 0.1, false )
- player.beenHit = true
- end
- if enemies.health == 0 then
- --for i = 1, #enemies.objects do
- --enemy = enemies.objects [ i ]
- --Level.RemoveObject ( enemy )
- Hud.Message ( "You Killed Jason.\n\nBut Watch Out!\n He May Yet Return...", 3 )
- KillEnemy ()
- --end
- end
- end
- function CollectKey1 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the First Key...\nMake sure you collect all six!", 2 )
- end
- end
- function CollectKey2 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the Second Key...\nMake sure you collect all six!", 3 )
- for i = 1, #obstacles1 do -- Do not completely understand this part.
- obstacle1 = obstacles1 [ i ]
- Level.RemoveObject ( obstacle1 )
- end
- end
- end
- function CollectKey3 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the Third Key...\nMake sure you collect all six!", 3 )
- for i = 1, #obstacles4 do -- Do not completely understand this part.
- obstacle4 = obstacles4 [ i ]
- Level.RemoveObject ( obstacle4 )
- end
- end
- end
- function CollectKey4 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the Fourth Key...\nMake sure you collect all six!", 3 )
- end
- end
- function CollectKey5 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the Fifth Key...\nMake sure you collect all six!", 3 )
- for i = 1, #obstacles3 do -- Do not completely understand this part.
- obstacle3 = obstacles3 [ i ]
- Level.RemoveObject ( obstacle3 )
- end
- end
- end
- function CollectKey6 ( target, source )
- if target == player.object then
- player.items = player.items + 1
- Level.RemoveObject ( source )
- Hud.Message ( "You've collected the Sixth Key...\nMake sure you collect all six!", 3 )
- for i = 1, #obstacles2 do -- Do not completely understand this part.
- obstacle2 = obstacles2 [ i ]
- Level.RemoveObject ( obstacle2 )
- end
- end
- end
- function CollectCoin ( target, source )
- if target == player.object then
- player.score = player.score + 1
- coins = Level.GetObjects ( "D" )
- Level.RemoveObject ( source )
- Hud.Message ( "You Found A Dollar!", 1.5)
- end
- if player.score == 1 then
- Hud.Message ( "Every Dollar Has Been Found!", 3 )
- end
- end
- function BushBite ( target, source )
- if target == player.object then
- if player.beenBitten == false then
- player.health = player.health - 20
- Level.RemoveObject ( enemy )
- Timer.Start ( "BiteAgain", 1, true)
- Timer.Start ( "RegainHealth", 20, true )
- Timer.Start ( "SpawnEnemy",1 , false )
- end
- end
- if player.health == 0 then
- Level.RemoveObject ( player.object )
- Sound.Play ( sounds.dying )
- Timer.Stop ( Timer.Start( "SpawnEnemy", 1.0, true ))
- Hud.Message ( "GAME OVER\n\n You Have Died",5 )
- player.pause = true
- --Timer.Start ( "GameOver", 1, true )
- GameOver ()
- end
- end
- -- TimeOuts
- function RegainHealth ()
- player.health = player.health + 1
- if player.health == 40 then
- Timer.Stop ( Timer.Start ( "RegainHealth", 20, true ) )
- end
- end
- function BiteAgain ()
- player.beenBitten = false
- end
- function HitAgain ()
- player.beenHit = false
- end
- function GameOver ()
- if player.pause == true then
- Hud.Message ( "Exit and restart game to retry.\n\n\nNo use staring at the screen...\nNothing is gonna happen.", 100 )
- end
- end
- function canFireAgain ()
- player.canFire = true
- end
- function SpawnEnemy()
- if not player.pause then
- spawning = Level.Spawn ( "Enemy", 64,1600,1400, "BushBite" )
- Timer.Start ( "KillEnemy", 5, true )
- end
- end
- function KillEnemy ()
- Level.RemoveObject ( enemy )
- Timer.Start ( "SpawnEnemy",3 , false )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement