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

dan11's Comments

Back to dan11's profile

I feel like it should be called Unlimited Fire :)
Do the bullets delete themselves when they reach the edge of the world? It seems to lag after a while.
Thanks!
@alikhan post the code on "discuss" as well as what you want to do. Most people will only help if they can see what you have; they don't want to write all your code for you. Also, their are many scenarios on Greenfoot where you can view the code. I would recommend looking at those scenarios. Again, post what you have in "discuss" so people can know what exactly you need help with.
@alikhan A great place to find someone to help you would be the "Discuss" part of Greenfoot. That way, you can post code, and others can post code to help you. If you post in "Discuss", myself or someone else may be able to help you.
Yes, I just put it as Math.sqrt((speed*speed)/2) to show a thought process. Speed*speed is c^2 in the Pythagorean Theorem, half of that is a^2 or b^2, and the square root of that is a or b, (only if the right triangle is isosceles of course). Any of the ways @danpost listed look neater and are more simplified; again, I only wrote it as I did to show a thought process. Again, sorry if I am making things more confusing.
In my games that are 8-directional, I usually import the provided SmoothMover class and move Math.sqrt((speed*speed)/2) in two directions. For a speed of two, for example, that would be the square root of two in two different directions to move two pixels diagonally, as (sqrt 2)^2 + (sqrt 2)^2 = 2^2, (Pythagorean theorem, the two bases (x,y) must be sqrt 2 to make the hypotenuse 2, the hypotenuse being the the diagonal distance moved). Sqrt 2 is a decimal number, so one must use SmoothMover or a similar system to track movement. Speed of 3 would be sqrt 4.5 in two directions (sqrt 4.5)^2 +(sqrt 4.5)^2 = 3^2 Speed of 4 would be sqrt 8 in two directions (sqrt 8)^2 +(sqrt 8)^2 = 4^2 And so on... For games that require 360 degree movement, I would use trigonometry. Sorry if my explanation is not too clear
One minor thing is that while moving up/down/left/right he moves slower than he does when he moves diagonal. For example, if he is moving 7 cells per act cycle when going up/down/right/left, while going diagonal he would be moving 7 cells in each direction, ending up with him moving approximately 10 cells diagonal, (the square root of 98 to be exact). Just something to think about if you really want to fine tune your game. Sorry I nitpick, it just bothers me :)
Cool. However, if you move diagonal, you should face diagonal.