## Walls!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

### Walls!

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
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

Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

### Re: Walls!

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.

GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

### Re: Walls!

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


Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Walls!

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.

baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

### Re: Walls!

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

baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

### Re: Walls!

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

tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

### Re: Walls!

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.

### Who is online

Users browsing this forum: Bing [Bot] and 29 guests