The Daily Click ::. Forums ::. Klik Coding Help ::. Pole Swinging and Trigonometry
 

Post Reply  Post Oekaki 
 

Posted By Message

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
8th June, 2004 at 14:38:02 -

I'm having trouble making a horizontal (coming out of the screen) pole swinging mechanism for a game I'm working on, but before I get into the problem, I should probably explain how my engine works. The whole character movement is based around four fastloops, one for each direction (up, down, left, right), which move the character and all associated parts/detectors one pixel, then check for collisions. Which loops are triggered depends on the direction (controlled by the player's alterable value B), and the state (walking, jumping, falling, etc.) of the player. How many times a loop is triggered depends upon alterable values A & B of a static active object for X and Y movement respectively. When the player's flag 0 is off, then those values are in a set proportion to a speed counter (10 - 40), but I can directly control them if I turn the flag on. When the alterable value A of the bottom detector is greater than zero, I subtract one from it, then trigger the "Up" loop however many times is dictated by the rate object's alterable value.

Anyway, after you touch a horizontal pole, you automatically start swinging clockwise or counter-clockwise depending on your initial direction. The animation direction of the swinging is determined by "Back Hand"'s alterable value A going from 0 to 31, cycling and resetting in the proper direction. When the player presses Fire 1, I convert the direction to degrees by the equation (Value A( "Back Hand" ) + 1 ) * 360 / 32. I tried to set the jump height to sin(angle) * 40, the X rate to Abs(sin(angle)* speed / 5), and the Y rate to Abs(cos(angle) * speed / 5), but it only seems to work properly in quadrant I (0 - 90 degrees, East to North). I'm sure there's an easier way than coding each angle individually, so what values should I use?

Image Edited by the Author.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
10th June, 2004 at 12:51:09 -

Okay, my equations are right. Sine is only positive in quadrants I and II, and cosine is only positive in quadrants I and IV. However, with a little experimenting, it seems as if TGF with the Advanced Math Object isn't recognizing negative trigonometric answers. Importing my engine into MMF, and replacing all Advanced Math Object code with MMF's built-in trig functions, it works. I had hoped to procrastinate as long as possible, but now it looks like I have to learn MMF. I love its power, but absolutely hate the counter-intuitive interface choices...if only it had kept TGF's! Anyway, here's some more n00bish questions for those too daunted by the long explanation earlier to reply :

1. How the heck do you change the size of an object in the picture editor, or even check at glance each animation frame's dimensions? I relied on the simple edit boxes where you could quickly change dimensions, hotspots, or action points in TGF, so where's the equivalent?

2. Is there any way to change the default transparent color from white to that fugly bluish green color in TGF? I hate not being able to tell at a glance whether a pixel is white or actually transparent.

3. While I'm asking, does anybody remember what keyboard shortcut let you automatically center the hotspot in an active object?

Image Edited by the Author.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
10th June, 2004 at 12:54:40 -

1. Go to Objects>Enlarge canvas (or Control+W)
2. Hold shift and click the desired colour at the bottom
3. Use the numberpad (with number lock on)

 
n/a

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
10th June, 2004 at 13:04:41 -

Thanks! MMF's help and on-CD tutorial was frustratingly useless. Sorry, but I have another question: how do you draw circles and ellpses from their centers, like in TGF?

Image Edited by the Author.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Kramy



Registered
  08/06/2002
Points
  1888
10th June, 2004 at 14:01:18 -

You pick the circle width, and drag from -(1/2 of that) to (1/2 of that)

Actually, I don't think there is a way, but I find dragging from the center extremely hard to get the circle pixel-perfect sizes.

 
Kramy

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
12th June, 2004 at 11:53:19 -

Thanks anyway. I come again with yet another question.

How do you import outside files as specific animation frames? Fiddling around, I figured out how to create a one-framed active object by create new object...from file, and the File->Import->Bitmap menu item, but it doesn't seem to actually import it as an animation frame.



 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
12th June, 2004 at 18:32:36 -

Create an Active Object, edit the animation you want to insert a picture to, and do the same (File > Import > Bitmap).

 
n/a

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
13th June, 2004 at 14:15:36 -

Thanks.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames
   

Post Reply



 



Advertisement

Worth A Click