Walls!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
baconhawka7x
Party member
Posts: 484
Joined: Mon Nov 21, 2011 7:05 am
Contact:

Walls!

Post by baconhawka7x » Mon Nov 21, 2011 7:16 am

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

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

Re: Walls!

Post by Kadoba » Mon Nov 21, 2011 10:23 am

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.

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

Re: Walls!

Post by GijsB » Mon Nov 21, 2011 2:47 pm

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

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

Re: Walls!

Post by Robin » Mon Nov 21, 2011 3:09 pm

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.
Help us help you: attach a .love.

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

Re: Walls!

Post by baconhawka7x » Mon Nov 21, 2011 6:48 pm

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

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

Re: Walls!

Post by baconhawka7x » Tue Nov 22, 2011 10:43 pm

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

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

Re: Walls!

Post by tsturzl » Wed Nov 23, 2011 1:05 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests