Computer Science Canada [Tutorial] Rotation and Movement |
Author: | AsianSensation [ Sat Feb 07, 2004 11:05 am ] | ||||||||
Post subject: | [Tutorial] Rotation and Movement | ||||||||
This is a tutorial on teaching how to make a image move toward the direction they are facing.
This is the entire code, the picture is uploaded on the bottom. Now I will go into a indepth explaination of the above code. First, find a picture of the right size that you would wish to rotate, like Pac-Man or something. now
Pic.Rotate let you create a new picture at a certain angle, from an original picture, rotating about a certain point. The tricky part here is you need to find the point of rotation. To find it, draw a circle around the entire picture, and find the center of the circle. That would be your point. Notice that if your center of rotation is off, some part of the picture could be cut off. So play around with either the picture or the center until you find a suitable one (Notice how this would be a much easier job if your object to rotate was circular, or near circular.) Next, I declared a variable "counter", which would keep track of what angle my rotation is.
lastly, I draw the picture of that certain angle, View.Update and whatnot, and we are done. since compsci doesn't let me upload bmps, and I have no other image editing tool as of right now, I'll just link the image. http://members.lycos.co.uk/asiansensation8733/hpbimg/spaceship.bmp |
Author: | Cervantes [ Sat Feb 07, 2004 11:25 am ] |
Post subject: | |
really good tutorial. with that it wouldn't be hard to make your own version of the SpaceGame that comes with Turing. |
Author: | TheXploder [ Sat Feb 07, 2004 11:25 am ] |
Post subject: | |
Thanx a lot AsianSensation I was trying to get that for weeks. Great Tutorial. Is creating 36 pictures efficient? |
Author: | AsianSensation [ Sat Feb 07, 2004 11:48 am ] |
Post subject: | |
yeah, 36 images is usually efficient. But if you want more precise rotation, you have to have more pictures. This is where loading bars comes into play. |
Author: | Paul [ Sat Feb 07, 2004 11:59 am ] |
Post subject: | |
Thanx alot! I'd give you bits, but you already have 1000 max. If I were to make a game using this kind of code and a bmp, would collision detection with coordinates be better than with whatdotcolor? |
Author: | TheXploder [ Sat Feb 07, 2004 12:04 pm ] |
Post subject: | |
but you could have only one image saved in memory at a time, and free the other images... |
Author: | recneps [ Sat Feb 07, 2004 12:09 pm ] |
Post subject: | |
no, the imagesd are stored in arrays, and the image is changed when the angle changes, see? |
Author: | AsianSensation [ Sat Feb 07, 2004 12:10 pm ] |
Post subject: | |
Paul Bian wrote: Thanx alot! I'd give you bits, but you already have 1000 max. If I were to make a game using this kind of code and a bmp, would collision detection with coordinates be better than with whatdotcolor?
whatdotcolor is evil! Evil I tell you! Seriously though, in a fast action paced game, whatdotcolor would not be as precise as using math and equations of coordinates to detect collision. TheXploder wrote: but you could have only one image saved in memory at a time, and free the other images...
I am pretty sure calling a picture stored in memory is alot quicker than generating a picture and then freeing it and then generating another picture. That's why at the beginning of your game, make a intro, and generate all your pictures in the background. (and don't use processes to do it.) |
Author: | Boiq [ Mon Sep 08, 2008 11:01 am ] |
Post subject: | RE:[Tutorial] Rotation and Movement |
Great tutorial. This guide helped me a great amount, thanks! |