This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

nadeemabdulhamid
nadeemabdulhamid presents ...

2009/3/27

bumpercars-v2

No description.

3191 views / 753 in the last 7 days

Tags: game demo with-source

open in greenfoot
Your browser does not support the canvas tag.
mjrb4mjrb4

2009/3/27

Hey, nice start here! I like the health bars and how the vehicles are eliminated :) Few pointers if you're looking to improve things a bit that I noticed: - Perhaps stop the game with a winner sign when there's only one left? That should be pretty easy - Colour code the vehicles so it's easy to tell which ones which - Objects - things like bombs could be interesting as well as the bricks - Levels - perhaps you have to get round a course without destroying the car? And if you're looking for a bit more of a challenge, here's another couple of (harder) ideas: - Car physics are quite hard to get right, and while you'll notice things seem ok if you're travelling fast, when you go slowly the turning gets a bit unrealistic. - The AI doesn't seem that clever at the moment, for me anyway it just drove into the wall and stopped until it died! Great start though, keep it up!
A new version of this scenario was uploaded on Fri Mar 27 21:53:00 UTC 2009
This is a demo I made to get my class started on their own Greenfoot games. I've just updated it with source code. An interesting thing in this project was a general-purpose StatusBar class that can be attached to other Actors, or independently placed in the world. The computer-controlled car moves completely randomly -- there's no AI in there. Right now the left/right arrow keys (or a/d for the second car) simply rotate the car as it's moving... what would you suggest for more realistic turning?
mjrb4mjrb4

2009/3/28

Ah, I'd seen the status bar pop up in a number of other scenarios and then guessed it was a general thing, nicely done. In terms of more realistic turning, you'd need to calculate the centre of the rotation of the car and have it rotate around that rather than at its centre (though when it's moving quickly and rotating it seems to rotate around a point roughly near the centre, so that's why it doesn't seem so bad.) The centre of rotation of a car is actually given by the intersection point of the normals of the two innermost wheels - so say you hard coded that the wheels would always turn 20 degrees, when you turned left you'd take the intersection point of the normal coming out the back left wheel (which would just be at 90 degrees to the car) and the the normal coming out of the front left wheel. This intersection point would then be the centre of rotation for the car (if you look in the support classes section there's already a method there to rotate around a point rather than just at the centre of the image.) Not the most trivial thing in the world to implement, but as a challenge task or something similar it could work well! One of the things on my to do list that I've never got round to has been to write a scenario with relatively realistic car physics (turning, drifting, acceleration with different gear ratios etc.) - there's a heck of a lot of physics there and it's really a case of going as complicated or as simple as you like :)

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.