Page 1 of 2

Hammer smashed face

Posted: Mon Dec 12, 2011 8:49 pm
by jradich
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:

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
I'm also posting my newest .love.

Re: Hammer smashed face

Posted: Mon Dec 12, 2011 10:34 pm
by Robin
Something odd happens when you go to left and press x at the same time. I guess you don't have an animation for "hammering while going left" yet.

Re: Hammer smashed face

Posted: Tue Dec 13, 2011 12:13 am
by jradich
Yeah and I'm having trouble making another function that doesn't conflict with the present one for x.

Re: Hammer smashed face

Posted: Tue Dec 13, 2011 2:02 am
by waraiotoko
This is hilarious.

Re: Hammer smashed face

Posted: Tue Dec 13, 2011 2:05 am
by jradich
waraiotoko wrote:This is hilarious.
In what sense, my good sir. Hehe, good sir.

Re: Hammer smashed face

Posted: Tue Dec 13, 2011 8:08 pm
by josefnpat
New Issue:
Assign to: jradich
Type: Bug
Priority: Major
Content:

As I may be able to hammer, and hammer smash, I am unable to hammer smash face.
Running: Ubuntu Linux 11.10 x86_64
To Reproduce: Run game, hammer smash with x key.

Re: Hammer smashed face

Posted: Wed Dec 14, 2011 7:05 pm
by SoggyWaffles
Thats a "huge" file for very very little going on. Also, is anything supposed to happen?

Re: Hammer smashed face

Posted: Wed Dec 14, 2011 8:14 pm
by The Burrito
If you're just going to mirror the sprites anyway you could simply set the X scale to -1 when drawing and add the width of the sprite to the X position whenever you're facing left.

also lols.

Re: Hammer smashed face

Posted: Wed Dec 14, 2011 9:18 pm
by jradich
SoggyWaffles wrote:Thats a "huge" file for very very little going on. Also, is anything supposed to happen?
My good sir, nothing is really supposed to happen YET. It's a "huge" file because of the sounds and graphics. But as I get more knowledgeable about love there will be stuff happening.

Re: Hammer smashed face

Posted: Wed Dec 14, 2011 9:31 pm
by jradich
The Burrito wrote:If you're just going to mirror the sprites anyway you could simply set the X scale to -1 when drawing and add the width of the sprite to the X position whenever you're facing left.

also lols.
If you do not mind, my good sir, would you show me what you mean?