Fangames > Programming Questions

Spinning Cherry?

(1/2) > >>

Realtime911:
Can someone tell me how to make a spinning cherry attacks? like the one Flandere Scarlet attack on The Guy boss fight at KTK2?
Any help would be appreciated!
(Sorry if that is bad english)

Sudnep:
i dont know why the code thing is squished. probably a bug with the new forums

Put this in the cherry step event
(click to show/hide)Cherry Step Event:

--- Code: ---if spin = true {
scrSpin(orbitObject,orbitAngle,orbitSpeed,orbitRadius,orbitDirection,orbitX,orbitY) // spin object [if direction = 1 { clockwise } else { counterclockwise }]

if orbitRadiusMax > orbitRadius { orbitRadiusDec = true } // if radiusMax is greater than the current radius, decrease it
if orbitRadiusDec = true { orbitRadius += orbitRadiusDev; if orbitRadius > orbitRadiusMax { orbitRadius = orbitRadiusMax; orbitRadiusDec = false } } // decrease radius

if orbitRadiusMax < orbitRadius { orbitRadiusInc = true } // if radiusMax is less than the current radius, increase it
if orbitRadiusInc = true { orbitRadius -= orbitRadiusDev; if orbitRadius < orbitRadiusMax { orbitRadius = orbitRadiusMax; orbitRadiusInc = false } } // increase radius
}
--- End code ---

Scripts to make it run.
(click to show/hide)(Only use this one, spin code is just ran in the cherry step)
Make it Spin Code:

--- Code: ---//scrMakeCherrySpin(object,x,y,speed,direction,radiusMax,radiusDev)
var object,xx,yy,angle,fast,radius,dir,radiusMax,radiusDev;

object = argument0
xx = argument1
yy = argument2
fast = argument3
dir = argument4
radiusMax = argument5
radiusDev = argument6

if object != 1 { angle = point_direction(object.x,object.y,x,y) } else { angle = point_direction(xx,yy,x,y) }
if object != 1 { radius = distance_to_point(object.x,object.y) } else { radius = distance_to_point(xx,yy) }
if object = 1  { object = 9999 }
spin = true
orbitObject = object
orbitX = xx
orbitY = yy
orbitAngle = angle
orbitSpeed = fast
orbitRadius = radius
orbitDirection = dir
orbitRadiusMax = radiusMax
orbitRadiusDev = radiusDevdiusDev
--- End code ---

Spin Code:


--- Code: ---//scrSpin(Orbited Object,Current Angle,Speed,Radius,Direction,rx,ry)

orbitObject = argument0
orbitAngle = argument1
orbitSpeed = argument2
orbitRadius = argument3
orbitReverse = argument4
orbitX = argument5
orbitY = argument6

if (orbitDirection) {
     if orbitObject != 9999 {
          orbitAngle += orbitSpeed;
          x = orbitObject.x + orbitRadius * cos(orbitAngle * pi / 180);
          y = orbitObject.y - orbitRadius * sin(orbitAngle * pi / 180);
     } else {
          orbitAngle += orbitSpeed;
          x = orbitX + orbitRadius * cos(orbitAngle * pi / 180);
          y = orbitY - orbitRadius * sin(orbitAngle * pi / 180);
     }
} else {
     if orbitObject != 9999 {
          orbitAngle -= orbitSpeed;
          x = orbitObject.x + orbitRadius * cos(orbitAngle * pi / 180);
          y = orbitObject.y - orbitRadius * sin(orbitAngle * pi / 180);
     } else {
          orbitAngle -= orbitSpeed;
          x = orbitX + orbitRadius * cos(orbitAngle * pi / 180);
          y = orbitY - orbitRadius * sin(orbitAngle * pi / 180);
     }
}
--- End code ---

How to run it:

Run this script with variables associated like thie

--- Code: ---with(delicious_fruit) { scrMakeCherrySpin(object,x,y,speed,direction,radiusMax,radiusDev) }
--- End code ---
object =  object name ( if no object set it to 1 )
x = if no object, set this to x pos you want it to rotate around
y = if no object, set this to y pos you want it to rotate around
speed = how fast it rotates around object / x,y cord
direction = 1 for clockwise; 0 for counterclockwise (i forgot which one it is)
radiusMax = maximum radius it is allowed to expand to (for cases where you want the circle thing to expand out a certain amount)
radiusDev = the speed at which it expands

This is what I use to make shit spin. There are probably easier ways but this is how I do it.

RandomFangamer:
I think there is a way to make a sprite spin in the GameMaker Sprite editor





Of course, before you select this action you should double the canvas size and place the delicious fruit in the middle to keep the stem from getting chopped off

Realtime911:
Finally it works, Thank you for all replies!

Zurai:

--- Quote from: RandomFangamer on April 17, 2015, 05:32:58 PM ---I think there is a way to make a sprite spin in the GameMaker Sprite editor





Of course, before you select this action you should double the canvas size and place the delicious fruit in the middle to keep the stem from getting chopped off

--- End quote ---

Never do that! It takes way to much time. To make an object rotate around it's own x/y axis just put into the step-event of that object: image_angle += x.
That means, that every step (frame) the sprite angle of that object is rotated by x. As higher x, as faster it rotates. For clockwise rotation just use "image_anglé -= 5.
Important note: The origin of the sprite as to be the centered. So double-click on the sprite and click on "center". Done!

Navigation

[0] Message Index

[#] Next page

Go to full version