
-----------------------------------
paulkwatyra
Sun Dec 18, 2005 11:46 am

Space game start
-----------------------------------
Hey i a while back i made this game called ball bombs now im incorperating graphics into the game and i need help on how to rotate my ships instead of them just moving side to side so any help would be apreciated

-----------------------------------
MysticVegeta
Sun Dec 18, 2005 12:36 pm


-----------------------------------
Then you need a 3d engine my friend. Unless you plan to rotate it 2D which will look crappy.... Are you sure you can handle 3D Images?

-----------------------------------
paulkwatyra
Sun Dec 18, 2005 12:50 pm


-----------------------------------
lol i dont think so
isnt there some way just to rotate it?

-----------------------------------
pavol
Sun Dec 18, 2005 1:05 pm


-----------------------------------
you can use Pic.Rotate
for example
var pic, picRotated : int

pic := Pic.FileNew ("whatever.bmp")
picRotated := Pic.Rotate (pic, 90(this is the angle), 100 (x coordinate), 100(y coordinate))

Pic.Draw (picRotated, 100, 100, picCopy)

im not 100% sure how it works but if you mess around with it for a while you should understand
hope it helps

-----------------------------------
paulkwatyra
Sun Dec 18, 2005 1:16 pm


-----------------------------------
Yes but wouldnt that jump it from lest say if its going straight to the left?

-----------------------------------
pavol
Sun Dec 18, 2005 1:23 pm


-----------------------------------
i don't understand, what do you mean by 'jump it'

-----------------------------------
paulkwatyra
Sun Dec 18, 2005 1:35 pm


-----------------------------------
like it wouldnt be a smooth transition for rotatating it

-----------------------------------
pavol
Sun Dec 18, 2005 1:47 pm


-----------------------------------
you're right it wouldn't, but one thing you can do is store a rotated version of the picture for every degree 1 - 360 in an array and then when the user turns the ship right, for example, just display the ship at the 1st degree then the 2nd and so on to 90 degrees. the only problem with that is that it will probably make your game slower.

-----------------------------------
Cervantes
Sun Dec 18, 2005 4:45 pm


-----------------------------------
It would make your game slower, because you are storing a bunch of pictures.  But there's nothing you can do about it.  (Well, you don't have to store 360 pictures.  Storing 72 or 36 pictures looks fine.)  Furthermore, it's a heck of a lot better than rotating the pictures in the loop: Pic.Rotate is a slow function.

I haven't looked at your code, but it sounds as if you should read [url=http://www.compsci.ca/v2/viewtopic.php?t=3714]zylum's rotation tutorial

[url=http://www.compsci.ca/v2/viewtopic.php?t=3542]AsianSensation also wrote a tutorial on the same topic.

-----------------------------------
pavol
Sun Dec 18, 2005 6:54 pm


-----------------------------------
oh, and i forgot to mention something for your game. you might wanna use View.Update so there is no more flicker
just a suggestion

-----------------------------------
Albrecd
Sun Dec 18, 2005 6:58 pm


-----------------------------------
im not 100% sure how it works but if you mess around with it for a while you should understand

Pic2 := Pic.Rotate (Pic1 you're right it wouldn't, but one thing you can do is store a rotated version of the picture for every degree 1 - 360 in an array

You definatly don't need 360 pictures, 36 usually works nicely.
You could try:


var pic : array 1 .. 36 of int

pic (1) := Pic.FileNew ("pic.bmp")
pic (2) := Pic.Rotate (pic (1), 10, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (3) := Pic.Rotate (pic (1), 20, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (4) := Pic.Rotate (pic (1), 30, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (5) := Pic.Rotate (pic (1), 40, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (6) := Pic.Rotate (pic (1), 50, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (7) := Pic.Rotate (pic (1), 60, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (8) := Pic.Rotate (pic (1), 70, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (9) := Pic.Rotate (pic (1), 80, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (10) := Pic.Rotate (pic (1), 90, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (11) := Pic.Rotate (pic (1), 100, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (12) := Pic.Rotate (pic (1), 110, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (13) := Pic.Rotate (pic (1), 120, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (14) := Pic.Rotate (pic (1), 130, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (15) := Pic.Rotate (pic (1), 140, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (16) := Pic.Rotate (pic (1), 150, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (17) := Pic.Rotate (pic (1), 160, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (18) := Pic.Rotate (pic (1), 170, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (19) := Pic.Rotate (pic (1), 180, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (20) := Pic.Rotate (pic (1), 190, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (21) := Pic.Rotate (pic (1), 200, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (22) := Pic.Rotate (pic (1), 210, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (23) := Pic.Rotate (pic (1), 220, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (24) := Pic.Rotate (pic (1), 230, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (25) := Pic.Rotate (pic (1), 240, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (26) := Pic.Rotate (pic (1), 250, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (27) := Pic.Rotate (pic (1), 260, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (28) := Pic.Rotate (pic (1), 270, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (29) := Pic.Rotate (pic (1), 280, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (30) := Pic.Rotate (pic (1), 290, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (31) := Pic.Rotate (pic (1), 300, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (32) := Pic.Rotate (pic (1), 310, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (33) := Pic.Rotate (pic (1), 320, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (34) := Pic.Rotate (pic (1), 330, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (35) := Pic.Rotate (pic (1), 340, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))
pic (36) := Pic.Rotate (pic (1), 350, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))


Then you draw pic (#) depending on what angle you what the picture at.

%NOTE: this code will rotate the picture around it's centre.

-----------------------------------
Albrecd
Sun Dec 18, 2005 7:04 pm


-----------------------------------
MysticVegeta Said:
Then you need a 3d engine...

Why would you need a 3D engine?

-----------------------------------
pavol
Sun Dec 18, 2005 7:15 pm


-----------------------------------
Well, you don't have to store 360 pictures
You definatly don't need 360 pictures
ok, i was exaggerating. Albrecd a for loop would make that code a bit easier. :D 
var pic, picR : int
pic := Pic.FileNew ("pic.bmp")

for i : 1 .. 36
    picR (i) := Pic.Rotate (pic, i * 10, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2)))
end for

-----------------------------------
Albrecd
Sun Dec 18, 2005 7:45 pm


-----------------------------------
I don't mean to be critical and I definatly think that a for loop is the way to go but the code you posted:


var pic, picR : int 
pic := Pic.FileNew ("pic.bmp") 

for i : 1 .. 36 
    picR (i) := Pic.Rotate (pic, i * 10, picX + (Pic.Width (pic (1)) div 2), picY + (Pic.Height (pic (1)) div 2))) 
end for

Will return an error because you have not declared all of your variables.

Instead of
var picR : int

you need
var picR : array 1 .. 36 of int

Otherwise it tries to use i as a subscript for picR rather than using it to determine which picR to use.

-----------------------------------
pavol
Sun Dec 18, 2005 7:52 pm


-----------------------------------
typo. forgot about that part.
you're right
