News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Clowns 'n' Balloons final released !!!

Started by micky4fun, April 24, 2009, 02:51:10 PM

Previous topic - Next topic

micky4fun

#45
Hi BlinkOk

nope its me , i got it wrong , ive mess about with my old code to get clown up and down with standing up to start then tucking up into ball , then coming out of ball to land and its ok , but im now going to start againas code was very messy and still had cannon , balloons , hud etc to do , so i might as well do it again now i know how im going to do it

so off we go

mick ;D

ps , so glad i started again , found a nice and easy way of doing animations , was getting right involved before , nice n easy now ,


BlinkOk

good to see it's workin out.
i tinkered with the splash after some sage advice from a friend.



Download splash

micky4fun

#47
Hi BlinkOk

yes nice splash screen , it looks great , also for to say a few posts back that's a great title for the game


ok ive been mucking around and have decided to use the turnsprite command for most of the animation
wanted to post a little demo , to see what you think so far , see if its worth going this way or not

yep most of gfx not used yet , just getting clown in air animations first
for ease use mouse to controll see-saw

mick :)

BlinkOk

#48
looks great mike. i think you might be playing the "landing" aninmation twice when hes coming down though. it really looks smooth and natural though. you could even do that when he misses and make him crouch and jump accross to the cannon.

ps: i just had another look at this and i think this might work;
when he's falling he can straighten up from the tuck. then he should remain straight until he hits the ground. then play the crouch animation. i reckon that will work a treat

micky4fun

Hi BlinkOk

yep i see what you meen about repeat animation on way down ,
im at work now and will cprrect that , to your ps sugguestion , i will then do the get him into cannon again routeen and so on


as for him busting the balloons , my last clown had a pin on hes head , and went up strainght and only burstedballoons on up movement , will this clown he has no pin and is spinning around , so i think ile do the bust where hes head touches the balloons either up or down , what do you think?

mick :)

BlinkOk

sounds cool. it's really up to you.
if you would like some sort of graphic thing that says he busts balloons on the way up i can do that. if you want him to bust balloons all the time then thats ok too.

micky4fun

#51
Hi BlinkOk and all

i did not have a lot of time today , but spent most of it stuck in working out the distance of when clown falls to get him back into center of cannon not just anyware near cannon
so can someone please help as my maths are rubbish , the formular is around line 200 , is there away of calculating the amount needed for volclownx# ? 
or another way of doing it , the center of cannon is at screen point 100 (x)

use images from above post
once the clown hits the floor he will make hes way to cannon , for 10 seconds then just fire out again , at the moment

thanks
mick :)

kevin


micky4fun

#53
Hi Kevin

thanks for reply , but i knew the distance was (clownx#)  minus (100 the connons posistion) i wanted to bounce clown over to it ,
so i used ,
                          cpos#=clownx#
      cal#=clownx#-100 (then cannons posx)
      if cal#>500 then xx#=cal#/8
      if cal#<=500 then xx#=cal#/4
      if cal#<=200 then xx#=cal#/2
                          i = i-2
                          clownx#=CosRadius(i,xx#)+cpos#-xx#
                          clowny#=SinRadius(i,300)+650 (650 the floors posy)
                          if i<-180
                  i=0
                  cpos#=cpos#-xx#*2
                         endif

                         back around again till clown reaches cannon

i know this may not make much sence without rest of code , it will do for now , maybe someone that knows better maths that me can tidy this bit up

thanks
mick :)

BlinkOk

try this mick.
when the clown hits the floor (from then on) make the cannon point towards the clown and move towards it.
that should naturally make the cannon collect the clown. the cannon can only collect the clown when he is falling (not rising)

u9

That is a brilliant suggestion.

micky4fun

#56
Hi all ,

hi BlinkOk

well only one clown here ,, me

its been a long day today , spent lots and lots of time trying to do when clowns hit floor over halfway to right of screen to make him bounce to right so i can get cannon comeing from right hand side as well ,
i gave up as you can see , but maybe an easy way of doing it , i tried to reverse my going to left code , but he still went left , adjusted a few values  , think he landed in mexico well he flue of the screen , never to be seen again

ok deleated last clown n balloons post , so ile post where im at now , not a lot of progress today in the end .. nevermind

mick :)

ps  think i need a new wheel , mines looks buckled , lol


u9

Here is how i did the clown-bounce-into-cannon thingy.

First calculate the horizontal difference between the clown and cannon:


diff# = clownx# - cposx#


Then i calculated (or measure) how many pixels my clown could max travel every bounce. In my example he traveled 244 pixels, so i calculated how far he had to travel every bounce with a little math... don't be scared though, it is quite simple:


numBounces = roundup( abs(diff#) / maxBounce )
travelEachBounce# = diff# / numBounces


An important thing to notice here is that no matter where you place the cannon (left or right of clown), travelEachBounce# can be positive or negative, so this will always work.

Lets try out a few examples:

In my cannon bounce example my clown could travel 244 pixels horizontally every bounce. So if we have the cannon at 100, and clown at 545 we find:


diff# = clownx# - cposx#  =  545 - 100  =  445
numBounces = roundup( abs(diff#) / maxBounce )  =  roundup( abs(445) / 244 )  =  roundup( 1,8 )  =  2
travelEachBounce# = diff# / numBounces  =  445 / 2  =  222.5


so make your clown travel 222.5 pixels for every bounce and he will surely land in the cannon.

Another example, just to show it also works in the other direction. Lets say the cannon is at x pos 1000, and the clown is at 55. Then we get:


diff# = 55 - 1000  =  -945
numBounces = roundup( abs(-945) / 244 )  =  roundup( 3,8 )  =  4
travelEachBounce# = -945 / 4  =  -240.1


Notice how travelEachBounce# is now negative...

Hope it helps.

micky4fun

Hi u9

thanks for the reply ,

think i know what you are saying , could you give a snippet on how i would then use the example in my program , using the CosRadius , sinradius  or sin and cos to more clown in either direction ?

also im also thinking of just getting the cannon to the clown so he only does 1 bounce , as said in post by blinkOk

thanks
mick :)

u9

#59
EDIT: rewritten.

Ok i think this is a good way of doing it using cos and sin. Put this in your main loop. It calculates a point half the distance the clown can travel each point, then using cos and sin it moves the clown around this point to the other side. It repeats until you stop it by setting isGoingToCannon to false. You could do that when the clown is close enough to the cannon.


if isGoingToCannon
   // Remember to set isGoingToCannon to false when clown enters cannon!

   // if clown is on ground, calculate how much to travel this bounce and set him on his way
   if clowny# >= floor#
      diff# =  cposx# - clownx#
      numBounces = roundup( abs(diff#) / MAX_BOUNCE_DIST )
      travelEachBounce# = diff# / numBounces

      // Calculate an anchor (center of circle) of which to bounce around, so we can use cos and sin around this point
      bounceAround# = clownx# + travelEachBounce#/2
      angle# = 0 // this value increases during the bounce...
   endif

   angle# = angle# + PI# / STEPS // STEPS is how many frames a bounce should last.

   // Calculate clown's new positioin
   clownx# = bounceAround# + cos(angle#) * travelEachBounce#/2
   clowny# = floor# - sin(angle#) * BOUNCE_HEIGHT // BOUNCE_HEIGHT is how tall a bounce is... you can choose anything you want
endif


Remember to define the constants i have used here with appropriate values at the beginning of your code. Without having tried it, here are some guesses:


constant floor# = 700
constant MAX_BOUNCE_DIST = 200
constant STEPS = 60 // 60 frames, one second for each bounce
constant BOUNCE_HEIGHT = 130


EDIT2: I calculated diff# wrongly. I believe it should be like it is now, so in my previous posts, it was wrong too.