Page 1 of 1

Walls!

Posted: Mon Nov 21, 2011 7:16 am
by baconhawka7x
Hey I'm pretty new to game developement, but I am very determined. I hope you dont think im an annoying bastard because of thatXD
I am making a game and so far there is a EXETREMELY simple menu(not important right now..)
you push "return" and there is a red box (which you control with WASD and text in the top left saying "use the WASD keys to move!"

I'm obviously not gonna take this game to seriously, just hoping it could help me get into the programming shizdig:)
SO I NEED HELP WITH making a wall! or a solid object that the red box(the user) cant walk through, and i would prefer it not to be just boxes like in sidescrollers such as mario. maybe cheasy lines or something? anyways the MAIN POINT is i want a line, that the player cant walk through. I would really appreciate it if someone helped me!
and if you have any tips for newbies please tell me!:D
Here is my main.lua,

function love.draw()
love.graphics.print("Welcome! Press Enter To Start!:D", 180, 300)
love.graphics.setColor(255, 20, 20)
end
function love.keypressed(key)
if key == "return" then
function love.keypressed(key)
if key == "a" then x = x-5
elseif key == "d" then x = x+5
elseif key == "s" then y = y+5
elseif key == "w" then y = y-5
end
end

function love.draw()
love.graphics.draw( character, x, y)
love.graphics.print("Use the WASD keys to move!", 50, 50)
end
end
end


I set most of the variables inside of conf.lua which is..
function love.conf(t)
t.title = "Box Game!:D"
t.screen.width = 800
t.screen.height = 600
end
function love.load()
x = 400
love.keyboard.setKeyRepeat(10, 10)
love.graphics.setBackgroundColor(255, 255, 255)
love.graphics.setColor(20, 250, 20)
character = love.graphics.newImage("character.png")
love.graphics.setFont(28)
y = 300
end
THANKS!;D

Re: Walls!

Posted: Mon Nov 21, 2011 10:23 am
by Kadoba
Hello and welcome to the LOVE community. When posting on the board please surround any code clipping with

Code: Select all

 tags.

[quote]SO I NEED HELP WITH making a wall! or a solid object that the red box(the user) cant walk through[/quote]
You're going to need some collision detection for this. Try [url=http://vrld.github.com/HardonCollider/]Hardon Collider[/url]. 

[quote]I set most of the variables inside of conf.lua which is..[/quote]
The conf file should really only be for configuring love. It's better if you put the love.load declaration in the main.lua file.

Re: Walls!

Posted: Mon Nov 21, 2011 2:47 pm
by GijsB
You cant use more then once love.draw(), is not a function that has to be looped by you, löve itself does that already.
So, what your basic game main.lua should look like is like this :

Code: Select all

function love.load()
--stuff
end
function love.update()
--stuff
end
function love.draw()
--stuff
end

Re: Walls!

Posted: Mon Nov 21, 2011 3:09 pm
by Robin
GijsB wrote:You cant use more then once love.draw(), is not a function that has to be looped by you, löve itself does that already.
Actually, if you look carefully you'll see that what he does sort of works. It's by no way a good idea, though, in that you're definitely right.

Re: Walls!

Posted: Mon Nov 21, 2011 6:48 pm
by baconhawka7x
Kadoba wrote:Hello and welcome to the LOVE community. When posting on the board please surround any code clipping with

Code: Select all

 tags.[quote][/quote][/quote]
Thank you that helps alot
[quote]The conf file should really only be for configuring love. It's better if you put the love.load declaration in the main.lua file[quote][/quote][/quote]
ok! ill keep that in mind! thank yew!:D

Re: Walls!

Posted: Tue Nov 22, 2011 10:43 pm
by baconhawka7x
GijsB wrote:You cant use more then once love.draw(), is not a function that has to be looped by you, löve itself does that already.
So, what your basic game main.lua should look like is like this :

Code: Select all

function love.load()
--stuff
end
function love.update()
--stuff
end
function love.draw()
--stuff
end
omg thank you SOO much !:D

Re: Walls!

Posted: Wed Nov 23, 2011 1:05 am
by tsturzl
Depends on the lines you want, I think the best way to learn how collision works is to use Bounding Box collision, then maybe try and understand some more complicated collision checking methods. Bounding box is probably the simplest collision detection, as it can only detect collisions between rectangular shapes.

If you want something more complicated look into HardonCollider.