using rotate sprite to animate ambience circles

Started by LemonWizard, December 16, 2011, 12:46:18 AM

Previous topic - Next topic

LemonWizard

Hey, I'm going to share a simple Idea I came up with.
In just a few minutes here it'll be done if I can find the right image..
It's basically a trick which will make the appearance of sprites rotating.. but the image contains all the sprites in the circle to start with.

In the attached zip file, is the source, a compiled exe, for those of you who are lazy.
and two seperate image examples.

it takes the image specified and turns it into a sprite, turns on auto center handling, and then proceeds to rotate it at the center of the screen.
The first one which has the same amount of sprites is less convincing because I spent more time on the second one.


This is a simple way to get around having to do the math involved in the same animation IF the sprites are seperate. I also have attached the individual sprite image. =p

kevin

#1
 Sprite Orbits

  Here's a variation of the demo, but rather than pre-rendering the balls to an image, the demo manually rotates them.  



PlayBASIC Code: [Select]
      Image_Ball =LoadNewImage("Ball.bmp",2)
imagemaskcolour Image_Ball,rgb(255,255,255)

BallCount=8

BallAngle#=0
BallRadius=200

BallWidth =GetImageWidth(IMage_Ball)
BallHeight =GetImageHeight(IMage_Ball)

setfps 60

do
Cls

cx=mousex()
cy=mousey()


For lp=0 to BallCount-1
angle#=wrapangle(Ballangle#,lp*(360.0/BallCount))
x#=cx+cosradius(angle#,BallRadius)
y#=cy+sinradius(angle#,BallRadius)
angle#=wrapangle(angle#+180)
DrawRotatedImage Image_Ball,x#,y#,angle#,1,1,BallWidth/-2,BallHeight/-2,true+8
next

BallAngle#+=2

Sync
loop


LemonWizard

that's cool :P

This is all pretty useful stuff :D
I need to learn more about how to use cos and sin functions to do rotations and also how to check rotated collison :/

Say, player walks up to curved object.. player sprite is rotated along the same angle as the curved object.

Example:

kevin

#3
 Sonic the Hedgehog Loop Mock Up

  In this demo, the sonic character runs through the screen and around  the loop.   It works by simply aligning the character to a path, the tricky bit (in this example) was creating a path that matched the backdrop picture or there abouts.  



Video




Download

  Attached

LemonWizard

Kevin I love you so much right now. XD This is awesome.

ATLUS