-3
\$\begingroup\$

I am rewriting the Bad Roads game with pygame, for AI research, having extracted the assets from the APK file. I have the truck images and the background:

The background image, the truck body and the truck wheel are separate assets.

How do I set the truck to run on the road, recognizing the black edge as the road?

The general screen has a truck moving along a sloping mountain.

\$\endgroup\$
  • \$\begingroup\$ Note that we expect some sort of research effort in our questions. There is also the implication of ripping off somebody elses game; don't do it. This might be completely fine in the context of the question (the user reports objectives of research), but if you aim to publish, your in for a world of trouble. \$\endgroup\$ – Gnemlock May 7 '17 at 23:53
  • \$\begingroup\$ Did you just do a screensave while the game was running or did you actually get opened up the apk and found this background image? I'm pretty sure they just used a mesh similarly how other games do it. \$\endgroup\$ – Bálint May 8 '17 at 5:39
  • \$\begingroup\$ @Bálint, I extracted the apk and found these background image. \$\endgroup\$ – GoingMyWay May 8 '17 at 7:44
2
\$\begingroup\$

Note: I'd suggest to create your own, instead of ripping these off the original game. That will give you more control, and will avoid any copyright issues.


how to recognize the black edge as the road?

You don't, well, sort of.


You need an array with the heights of the terrain, such that you can use it to query for the ground at any given X coordinate.

You may want to process the image to get the heights, which would be done by going column by column, from left to right, checking the color of the pixels and exporting them to a file that you would then use in your code.


From watching the promotional video for the game you claim to attempt to clone, the terrain is not meant to be smooth. That means that working with a lower resolution and doing interpolation won't replicate the effect correctly.

Another thing to notice is that the trees are not obstacles. The approach above will have a problem with the trees because in the image the trees share color with the floor.

You can identify the trees rather easily (either by hand or by looking for picks in the data), what to replace them with? You can approximate the height of the ground where there is a tree by interpolating the surroundings.


In practice the heigh map is not the image, the image is just a visual representation for the user, but it is not mechanically relevant.

Note: the promotional video also shows the truck hitting a water tower, I'd suggest to place the coordinates for such obstacles by hand. Dealing with collisions is beyond the scope of this answer.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.