Page 1 of 1
Coding Help
Posted: Sat Feb 16, 2019 6:07 pm
by Steven Rafft
Hey! Im New At "LOVE2D" And Iam Making A Game And I Have A Problem... The Problem Is I Want When The Player Touchs The Spike It Prints Game Over Please Help.
Re: Coding Help
Posted: Sat Feb 16, 2019 11:38 pm
by keharriso
You'll have better luck getting help if you include a .love file or show some relevant source code. Are you new to programming in general, or just LÖVE? You're probably looking for how to detect collisions between two rectangles, aka "Axis-Aligned Bounding Boxes" (AABB).
Here's an article on that subject with source code that's easily converted to Lua.
Re: Coding Help
Posted: Sun Feb 17, 2019 5:36 pm
by Steven Rafft
Here is The Game Open The File And Continue And It Will Be Extracted
https://www.mediafire.com/file/4jc051tk ... e.exe/file (Its For Windows Only)
Re: Coding Help
Posted: Sun Feb 17, 2019 5:39 pm
by zorg
Instructions unclear, mediafire gave me a trojan and now my computer won't boot
But seriously, upload a love file without combining it with love.exe, onto the forums here; there's an upload attachment button.
Edit: Don't worry about it
It's just the safer way, and i actually did almost get one in the past from there... it depends on the ads they show you.
Re: Coding Help
Posted: Sun Feb 17, 2019 5:46 pm
by Steven Rafft
weird i'v never got a virus from mediafire but okay
i also didn't notice there is an attachment button sorry i'm new to the forums .
Re: Coding Help
Posted: Sun Feb 17, 2019 5:56 pm
by Steven Rafft
Here it's
Re: Coding Help
Posted: Sun Feb 17, 2019 6:00 pm
by Steven Rafft
ah not a problem i understand that popups can come randomly and make this happen but i think adblocker blocks them anyways
Re: Coding Help
Posted: Sun Feb 17, 2019 6:35 pm
by keharriso
1. Not critical, but you might want to look into using the "local" keyword when declaring your variables (global variables are, in general, bad practice).
2. This does absolutely nothing:
Code: Select all
love.timer.step(playerx - playery)
3. Get rid of the ox/oy arguments to draw (they just make the math more complicated):
Code: Select all
love.graphics.draw(playerimg, playerx, playery)
4. Initialize playery to be the correct value in love.load:
5. Check for collisions like this at the end of your love.update function:
Code: Select all
if playerx < 300 + 19 and
playerx + 29 > 300 and
playery < 220 + 13 and
playery + 16 > 220 then
print "Collision!"
end
Note that the above code is basically directly translated from that link I shared earlier.
Re: Coding Help
Posted: Sun Feb 17, 2019 6:48 pm
by Steven Rafft
where do i exactly put that code?
nevermind
Code: Select all
if playerx < 300 + 19 and
playerx + 29 > 300 and
playery < 220 + 13 and
playery + 16 > 220 then
print "Collision!"
end