score counter and putting objects to collect
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: score counter and putting objects to collect
Oops I that came out a little different than what I meant, I got pickup sounds down now all I need is to have the fruits swapped with another graphic when walked over, anyone have any idea how to do this? .
Re: score counter and putting objects to collect
The only way to really stop the player from getting massive points by standing on top of the fruit with the swapped graphic, is by making it a different kind of object. In the method where the collission with the item is detected, create a new entity with a different graphic but on the same location as the previous fruit.
I can't access your code from work so I can't really give any code based examples, but you really should try to figure this stuff out on your own anyway
I can't access your code from work so I can't really give any code based examples, but you really should try to figure this stuff out on your own anyway
Re: score counter and putting objects to collect
I'm very grateful for the help still working on the scoring
but here it is at its current state.
but here it is at its current state.
- Attachments
-
- the adventure of based god.love
- (3.37 MiB) Downloaded 124 times
Re: score counter and putting objects to collect
Hi - I'm somewhat new to coding and wondering about the same issue of object collection. For some reason when I download the two .love files in the thread above, I'm not able to open them, with love or with VSC. If anyone can advise me on a possible solution so I can benefit from the advice/help already offered, that would be rad
Re: score counter and putting objects to collect
This thread is 9 years old, which means the love files provided are using a heavily outdated version of LOVE2D. Many functions and methods from that version are deprecated. You'll probably get more help if you created a new thread (I think it's fine in this instance since this one is so old) and get more specific with your questions, code examples included.vires wrote: ↑Thu May 05, 2022 2:19 am Hi - I'm somewhat new to coding and wondering about the same issue of object collection. For some reason when I download the two .love files in the thread above, I'm not able to open them, with love or with VSC. If anyone can advise me on a possible solution so I can benefit from the advice/help already offered, that would be rad
That said, sounds like you want to do some basic collision and drawing logic. My game has lots of collectible objects (coins, powerups, etc), here is a simplified example of how I'm handling coin collection.
Code: Select all
function updateGold(dt)
if round.gameState == 2 then
for i,c in ipairs(coins) do
if distanceBetween(c.x, c.y, player.x, player.y) < 6 then -- basic 'collision' detection
gold.total = gold.total + c.value -- add the coin value to the players total gold
c.collected = true -- flag used to 'despawn' the coin once collected
end
end
for i=#coins,1,-1 do
local c = coins[i]
if c.collected == true then
table.remove(coins, i)
end
end
end
end
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Nikki and 6 guests