Hammer smashed face
Posted: Mon Dec 12, 2011 8:49 pm
Hello world. I'm new to love, so to start out, I made hammer smashed face, a lil' interactive scene. I'll be working on this, mind you, so don't judge this version so harshly. Enjoy.
EDIT: Ok, for the past few DAYS I have been trying to figure out how to make it so that once x is pressed, all other keys (up, down, left, right) just cancel. I'm having some problems with learning lua, mostly because of time restrictions and an overall confusion with some code that's involved. here is the main.lua: I'm also posting my newest .love.
EDIT: Ok, for the past few DAYS I have been trying to figure out how to make it so that once x is pressed, all other keys (up, down, left, right) just cancel. I'm having some problems with learning lua, mostly because of time restrictions and an overall confusion with some code that's involved. here is the main.lua:
Code: Select all
--For Private Use Only
function getRelativePositioning(ax1, ay1, aw, ah, bx1, by1, bw, bh)
local ax2, ay2, bx2, by2 = ax1 + aw, ay1 + ah, bx1 + bw, by1 + bh
local left, right, above, below = ax1 < bx1, ax2 > bx2, ay1 < by1, ay2 > by2
local inside = not (left or right or above or below)
return left, right, above, below, inside
end
function love.load()
player = love.graphics.newImage("graphics/patheticperson.png")--Loads Hammer guy. Duh.
x = 25
y = 50
speed = 50
background = love.graphics.newImage("graphics/background.png")--Loads Background.
Hammertime = love.audio.newSource("sounds/Hammer Smashed Face 8 bit.mp3", "stream")--Plays Hammer Smashed Face Continuosly!
Hammertime:setVolume(0.5)
Hammertime:setLooping(true)
love.audio.play(Hammertime)
end
function love.draw()--Loads everything into existance. Thank jeezus.
love.graphics.draw(background)
if love.keyboard.isDown("left") then
love.graphics.draw( player, x + player:getWidth(89), y, 0, -1, 1, 0, 0 )
else
love.graphics.draw( player, x, y )
end
love.graphics.print('Hammer Smashed Face! Press x to smash!', 0, 0)
end
function love.update(dt)--Brings movement to your angry hammer guy.
if love.keyboard.isDown("right") then
x = x + (speed * dt)
elseif love.keyboard.isDown("left") then
x = x - (speed * dt)
end
if love.keyboard.isDown("down") then
y = y + (speed * dt)
elseif love.keyboard.isDown("up") then
y = y - (speed * dt)
end
end
function love.keypressed(key)
if key == 'x' then--I'm angry, and to express my rage, I will hit you with my hammer.
player = love.graphics.newImage("graphics/patheticpersonshoot.png")
end
if key == 'f' then
love.graphics.toggleFullscreen( true )
end
if key == 'escape' then--RAGEQUIT!
love.event.push('q')
end
if key == 'up' then--He got hops.
player = love.graphics.newImage("graphics/patheticpersonjump.png")
end
if key == 'down' then--OH NO! FAAALLLLLLLLING!
player = love.graphics.newImage("graphics/patheticpersonfall.png")
end
end
function love.keyreleased(key)
if key == 'x' then--Stop it! He's already dead!
player = love.graphics.newImage("graphics/patheticperson.png")
end
if key == 'up' then--There comes a time where gravity pushes you around.
player = love.graphics.newImage("graphics/patheticperson.png")
end
if key == 'down' then--Look! The fall didn't hurt me!
player = love.graphics.newImage("graphics/patheticperson.png")
end
end