I've been trying to port car game on holydays from:
msx80
https://tic80.com/play?cart=573
The code is not mine, i have adapted some parts to run in love2d ... I'm a total beginner, sorry for my code :-)
To find out if the car is on asphalt or grass, the original author did it by comparing colors... I haven't found how to do it this way or any tutorial where someone describes how to check that in a car game.
And for what?
Well, so that the cars go more slowly when they leave the road.
Does anyone have an idea how to do it?
Car Game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Car Game
- Attachments
-
- car_pruebas_5.love
- (81.86 KiB) Downloaded 227 times
Re: Car Game
You can try loading the road image as ImageData instead of Image.
You can then create an Image out of the ImageData, but also keep the ImageData because that way you can access ImageData:getPixel.
So, instead of this:
you'd do this:
and then you can draw the image using imageFile just as before, and check pixels with imageData:getPixel(x, y).
You can then create an Image out of the ImageData, but also keep the ImageData because that way you can access ImageData:getPixel.
So, instead of this:
Code: Select all
imageFile = love.graphics.newImage("img/carretera2.png")
Code: Select all
imageData = love.image.newImageData("img/carretera2.png")
imageFile = love.graphics.newImage(imageData)
Re: Car Game
Hello good morning!
Thank you very much for your answer
This morning I have modified the code and I have added the modifications that you have proposed, as I am learning it is difficult for me to understand the logic, but I am working on it. I am attaching a modified version where I try to see the friction that is applied to the car when it is on and off the road... so far without much success. I'm still working and thank you very much for your help!
Thank you very much for your answer
This morning I have modified the code and I have added the modifications that you have proposed, as I am learning it is difficult for me to understand the logic, but I am working on it. I am attaching a modified version where I try to see the friction that is applied to the car when it is on and off the road... so far without much success. I'm still working and thank you very much for your help!
- Attachments
-
- car_pruebas_6.love
- (183.85 KiB) Downloaded 75 times
Re: Car Game
That's probably the limitation of that platform. Doing color comparisons is probably less straightforward way to do it than comparing car position with an underlying map. Another option instead of position checking is to do collision checking, where grass is a sensor and once car collides with a grass, sensor collision is triggered.paco72 wrote: ↑Sat Aug 26, 2023 10:12 pm To find out if the car is on asphalt or grass, the original author did it by comparing colors... I haven't found how to do it this way or any tutorial where someone describes how to check that in a car game.
And for what?
Well, so that the cars go more slowly when they leave the road.
Does anyone have an idea how to do it?
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests