Created
February 10, 2013 18:37
-
-
Save Benjmin/4750539 to your computer and use it in GitHub Desktop.
The keyboard isn't affecting it at all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function love.load() | |
kevin = {} | |
kevin.hearts = 3 | |
kevin.attack = "nothing" | |
kevin.charge = 1 | |
kevin.decided = false | |
enemy = {} | |
enemy.hearts = 3 | |
enemy.attack = "nothing" | |
enemy.attack_phase = 1 | |
enemy.charge = 1 | |
phase = "decide" | |
attacks = {"apply", "block", "charge", "strike"} | |
keyboardcs = {"a","b","c","space"} | |
dtotal = 0 | |
end | |
function love.keypressed(key, unicode) | |
-- Kevin logic for decision | |
if phase == "decide" and decided == false then | |
for i = 1, 4 do | |
if key == keyboardcs[i] then | |
kevin.attack = attacks[i] | |
kevin.decided = true | |
end | |
end | |
end | |
end | |
function love.update(dt) | |
dtotal = dtotal + dt | |
-- decision phase. | |
if phase == "decide" then | |
--enemy logic | |
for i = 1, 4 do | |
if enemy.attack_phase == i then | |
enemy.attack = attacks[i] | |
end | |
end | |
--phase logic for decision | |
if dtotal > 3 then | |
dtotal = 0 | |
phase = "fight" | |
end | |
end | |
-- fighting phase. | |
if phase == "fight" then | |
if dtotal > 3 then | |
dtotal = 0 | |
phase = "decide" | |
kevin.attack = "nothing" | |
kevin.decided = false | |
enemy.attack = "nothing" | |
enemy.attack_phase = enemy.attack_phase + 1 | |
end | |
end | |
--enemy logic | |
if enemy.attack_phase > 3 then | |
enemy.attack_phase = 1 | |
end | |
end | |
function love.draw() | |
love.graphics.print(phase,100,100) | |
love.graphics.print(kevin.attack,100,150) | |
love.graphics.print(enemy.attack,100,200) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment