Coding Help

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Coding Help

Post 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.
User avatar
keharriso
Party member
Posts: 109
Joined: Fri Nov 16, 2012 9:34 pm

Re: Coding Help

Post 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.
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Re: Coding Help

Post by Steven Rafft »

Here is The Game Open The File And Continue And It Will Be Extractedhttps://www.mediafire.com/file/4jc051tk ... e.exe/file :ultrahappy: (Its For Windows Only)
Last edited by Steven Rafft on Sun Feb 17, 2019 6:27 pm, edited 2 times in total.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Coding Help

Post 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 :P 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.
Last edited by zorg on Sun Feb 17, 2019 5:52 pm, edited 1 time in total.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Re: Coding Help

Post 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 .
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Re: Coding Help

Post by Steven Rafft »

Here it's
Attachments
Game.rar
(1.6 KiB) Downloaded 143 times
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Re: Coding Help

Post 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 :P
User avatar
keharriso
Party member
Posts: 109
Joined: Fri Nov 16, 2012 9:34 pm

Re: Coding Help

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

Code: Select all

playery = platformy - 16
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.
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
Steven Rafft
Prole
Posts: 6
Joined: Sat Feb 16, 2019 5:57 pm

Re: Coding Help

Post by Steven Rafft »

where do i exactly put that code?
nevermind :death:

Code: Select all

if playerx < 300 + 19 and
    playerx + 29 > 300 and
    playery < 220 + 13 and
    playery + 16 > 220 then
  print "Collision!"
end
Post Reply

Who is online

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