Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Space game start
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
paulkwatyra




PostPosted: Sun Dec 18, 2005 11:46 am   Post subject: 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


Space Battles.zip
 Description:

Download
 Filename:  Space Battles.zip
 Filesize:  1.1 KB
 Downloaded:  128 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sun Dec 18, 2005 12:36 pm   Post subject: (No subject)

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




PostPosted: Sun Dec 18, 2005 12:50 pm   Post subject: (No subject)

lol i dont think so
isnt there some way just to rotate it?
pavol




PostPosted: Sun Dec 18, 2005 1:05 pm   Post subject: (No subject)

you can use Pic.Rotate
for example
code:
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




PostPosted: Sun Dec 18, 2005 1:16 pm   Post subject: (No subject)

Yes but wouldnt that jump it from lest say if its going straight to the left?
pavol




PostPosted: Sun Dec 18, 2005 1:23 pm   Post subject: (No subject)

i don't understand, what do you mean by 'jump it'
paulkwatyra




PostPosted: Sun Dec 18, 2005 1:35 pm   Post subject: (No subject)

like it wouldnt be a smooth transition for rotatating it
pavol




PostPosted: Sun Dec 18, 2005 1:47 pm   Post subject: (No subject)

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.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Dec 18, 2005 4:45 pm   Post subject: (No subject)

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 zylum's rotation tutorial

AsianSensation also wrote a tutorial on the same topic.
pavol




PostPosted: Sun Dec 18, 2005 6:54 pm   Post subject: (No subject)

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




PostPosted: Sun Dec 18, 2005 6:58 pm   Post subject: (No subject)

Quote:
im not 100% sure how it works but if you mess around with it for a while you should understand


Pic2 := Pic.Rotate (Pic1 [picture that you want to rotate], x, y [x, y is the point around which you want the picture to rotate])

Quote:
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:

code:

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




PostPosted: Sun Dec 18, 2005 7:04 pm   Post subject: (No subject)

MysticVegeta Said:
Quote:
Then you need a 3d engine...


Why would you need a 3D engine?
pavol




PostPosted: Sun Dec 18, 2005 7:15 pm   Post subject: (No subject)

Quote:
Well, you don't have to store 360 pictures

Quote:
You definatly don't need 360 pictures

ok, i was exaggerating. Albrecd a for loop would make that code a bit easier. Very Happy
code:
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




PostPosted: Sun Dec 18, 2005 7:45 pm   Post subject: (No subject)

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:

Quote:
code:

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
code:
var picR : int


you need
code:
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




PostPosted: Sun Dec 18, 2005 7:52 pm   Post subject: (No subject)

typo. forgot about that part.
you're right
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: