Jump to content

detecting if car is offroad


Recommended Posts

Hello all,


not long time ago, i experimented a little bit with canvas and tried to make a small car race in it. because i didnt know phaser, i started everything from scratch without any framework.

but now that i know phaser, i love it and want to use it in my small game. but there is one thing i couldnt figure out how to do. maybe someone can give me a hint on how to start.


how it was without phaser:

i had a large jpg as background in canvas. the street was in black color, and offroad white ( background: https://github.com/daTobiGit/carRace/blob/master/images/map.jpg )

when i wanted to detect if the car is offroad, i took the pixel color (getImageData) from the background at the current position, and if it was different than black, the car was offroad.


now with phaser, i dont find a way how to do that. i can still load the background in a canvas, and use getImageData again, but maybe there is a much better and faster way how to do that.

maybe there is something with a tilemap, but the street cant be tiled properly, as it is painted ugly in m$ paint. maybe i can set a "street layer" somehow, and check collision or overlap with it?

any help is appreciated!


thanks in advance


Link to comment
Share on other sites

  • 11 months later...

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...