Jump to content
Sign in to follow this  
Czar

Canvas Project - rotating images?

Recommended Posts

I have been working on Game Canvas project

 

TCanvasProject = class(TW3CustomGameApplication)

 

I figured that this would be the best solution to make a game. However, I am running into some annoying limitations.

 

I have my player image

 

FImgPlayer : TW3Image;

 

And I draw it to the canvas using the handle

 

canvas.DrawImageF(FImgPlayer,

idx*49, 0, 49, 49,

FPlayer.x,

FPlayer.y,

49, 49);

 

Now the problem..

 

I would like to draw a rotated version of the image. I have checked as much as I could and I cannot find any draw functions that allow rotation.

 

So am I missing something? How do I draw a rotated version of the image?

Or it is there better solution for making games that allow the flexibility requited to scale and rotate images/sprites?

 

Are there any demos that show this?

Share this post


Link to post
Share on other sites

> I would like to draw a rotated version of the image. I have checked as much as I

> could and I cannot find any draw functions that allow rotation.

> So am I missing something? How do I draw a rotated version of the image?

> Or it is there better solution for making games that allow the flexibility

> requited to scale and rotate images/sprites?

 

Try TW3Sprite from SmartCL.Sprite3D unit. Also take a look at contents demos and games demos inside SMS demos, they are all some kind of games so they'll probably can give you some clues.

Share this post


Link to post
Share on other sites

Thanks, I have found a few examples using sprite3d so I will examine those. Spartacus and ZenSky are looking promising.

 

The missile command demo was a dead end for me even though on the surface it does much of what I was looking for.

Share this post


Link to post
Share on other sites

I will make a simple demo later but for now I will just post the relevant bit of code

 

Canvas.Save;

Canvas.Translate(FPlayer.x+25, FPlayer.y+25);

Canvas.Rotate(FPlayer.ang);

canvas.DrawImageF(FImgPlayer,

idx*49, 0, 49, 49,

-25,

-25,

49, 49);

Canvas.Restore;

 

Save the canvas before you start mucking around with it. Translate the origin point to where you want to draw the image. Rotate the canvas, draw the image and restore the canvas.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×