Hello,

I have created a game in java and I would like to insert enemies. For now I placed them on plaftforms that I made invisible.

How can I have the enemy on its own?

Recommended Answers

All 5 Replies

I have ... no idea whatsoever you are talking about.
what do you mean by 'placed them on platforms'. also, if you've already placed them on platforms, doesn't that imply your enemy is on its own platform?

please elaborate a bit more.

My question is how can I add a mass to a body?

I assume you have variables for its position and velocity that you update at regular intervals (Swing Timer) - in which case just add a fixed amount to the (downwards) vertical velocity component on each update. This will result in the downwards speed increasing steadily - just like g.

and after would be collision detection with the platforms when it detects the position of a platform it should stop the downward motion

a good example for this is a mario game
though deprecated here's a good example/tutorial I used as a base for my game a long time ago
http://www.javacooperation.gmxhome.de/PlatformGameBasicsEng.html

Thank you!! zeroliken

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.