Computer Science Canada need help with pic.rotate |
Author: | CodeMonkey2000 [ Thu Nov 02, 2006 7:05 pm ] | ||
Post subject: | need help with pic.rotate | ||
im making a game with a spider-bot-tank-thingy, and i need help with rotating the turret. i'm using pic.rotate, but when i rotate it, the whole turret doesnt show up. this isnt the full source, but just the part im having trouble with.
|
Author: | bruized [ Thu Nov 02, 2006 7:20 pm ] |
Post subject: | |
I think that all you need to do is create a large margin on the bottom and left side so that when it does rotate the picture it doesn't cut off your actual turret. |
Author: | CodeMonkey2000 [ Thu Nov 02, 2006 7:36 pm ] |
Post subject: | |
how would you do that? Pic.Rotate (picID, angle, x, y : int) : int x and y are where it should rotate, and angle is well, the angle. |
Author: | bruized [ Thu Nov 02, 2006 7:41 pm ] |
Post subject: | |
Your turret is imported from a picture right? All you have to do is edit the picture in Adobe Photoshop or something and add some space on the bottom and on the left. |
Author: | CodeMonkey2000 [ Thu Nov 02, 2006 7:46 pm ] |
Post subject: | |
the picture is not imported, at the begining it is drawn through turing's modules, and then it takes a "screenshot" and uses that as a reference later. |
Author: | bruized [ Thu Nov 02, 2006 7:48 pm ] |
Post subject: | |
Sorry, I'm not thinking clearly and not really paying attention. If I could I'd delete the post before, but i can't. If you were importing the picture then it would work but you're not... ![]() |
Author: | richcash [ Thu Nov 02, 2006 8:15 pm ] |
Post subject: | |
If you're picture is not imported, then why don't you rotate everything you draw in your turret using sine and cosine? |
Author: | bruized [ Thu Nov 02, 2006 8:25 pm ] | ||
Post subject: | |||
Either that, or you could simply draw the picture farther away from the bottom left and when you Pic.New simply leave more space on the bottom left hand corner. That way there is adequate space to allow for the clipping not to be seen (it only clips part of the background of the picture not the actual turret. Like so...
That was done quick so it may not be what you want it, but the main idea is I drew the picture farther away from the bottom left which left more room, yada yada yada. You get the point ![]() |
Author: | CodeMonkey2000 [ Thu Nov 02, 2006 10:34 pm ] |
Post subject: | |
wow, thnx |
Author: | Dan [ Thu Nov 02, 2006 11:18 pm ] |
Post subject: | |
Ack, each time that loop is run it is making a new pic and never freeing it. Affter some time it will use up all the space turing alows for pics and will crash. You need to add a Pic.Free at the end of the forlop. |
Author: | DemonZ [ Fri Nov 03, 2006 2:09 am ] | ||
Post subject: | |||
no no thats not it, if u want the pic to not cut off while rotating, the when you do Pic.Rotate (pic, angle, x, y) set the parameters of x and y as -1, this will rotate the picture in the specified margin without cutting it off, and if u want it to rotate according to the center, than just draw ur pic but when u do the x and y subtract the x and y values form the Pic.Height and Pic.Width of ur pic, here is some sample source-pseudo code for u to experiment and understand with:
This way your x and y are centered in the middle and ur boundaries are set to -1 so that all of the picture is rotated within the margins If u dont understand what I mean just ask. |
Author: | bruized [ Fri Nov 03, 2006 3:53 pm ] |
Post subject: | |
I definitely don't understand what you mean. I just don't really get it. It doesn't click. I also don't understand what Hacker Dan said. Was he talking about my code? When you pic.rotate it actually creates a totally new picture? or what... I'm kinda new and so I don't know a lot about Turing. |
Author: | CodeMonkey2000 [ Fri Nov 03, 2006 7:01 pm ] | ||
Post subject: | |||
i get what hackerdan was saying. if you let the privious program run, it will eventually slwo dwon ur comp, then crash.
not sure what demonZ mnet.... |
Author: | DemonZ [ Sat Nov 04, 2006 2:33 pm ] | ||||||
Post subject: | |||||||
ok first lets start with the basics: if u want to have a game where the player is going to rotate then you will need to familiarize yourself with these commands: COMMANDS Pic.Rotate arrays round sind cosd Pic.Height Pic.Width for loops These are just some of the most important commands youll need to know, first lets start with declaring some variables
Now lets assign the values to these variables
Now we will use a for loop to actually generate the rotated versions of the pic for i : 1 .. 35 picture (i) := Pic.Rotate (picture (0), i * 10, -1, -1) end for Now here are the controls for the tank to rotate
Now We Will put all of this together and we will get the picture to rotate |
Author: | DemonZ [ Sat Nov 04, 2006 2:47 pm ] | ||
Post subject: | |||
and if u didnt understand that, then here is an example of Pic.Rotate used in action with a box drawn in turing
sorry the last post had a couple mistakes in it that i forgot to correct this is how u do it |
Author: | Dan [ Sat Nov 04, 2006 2:56 pm ] |
Post subject: | |
It is an intresting idea to make all the anagles and save them as pics befor you start the game. It whould make the game run slightly faster but use up more memory. It is the calsic memory effsheny vs time effshenscy trade off. The thing to rember is that turing has a limt on how many pics it can have in memeory. So if your game is going to need alot of pics in memeory at one time it maybe best to use the dynamic creation of pics method so you only use up one pic place at a time. However since you are only using 35 pics in that area in most cases it probly whould be better to put them in the area like you are. Either way just rember to free the pics affter you are done with them other wise you will run in to issues. |
Author: | DemonZ [ Sat Nov 04, 2006 3:38 pm ] |
Post subject: | |
The way I suggested works, but if you prefer using less memory than try a different approach, I used this technique when I made the controls for my tank game and it ran good, only problem you might run itno your game is if your using projectiles and how to shoot them according to the angle and the collsion checking, in that case I can help you with it. |