Page 1 of 2 1 2 >
Topic Options
#199803 - 07/29/10 09:58 AM Reverse vertical direction
K1kk0z90


Registered: 07/29/10
Posts: 14
Loc: Italy
Hi all! laugh

How can I reverse only horizontal or only vertical direction of an active object?

At the moment I'm using the Bounce movement, but I'd prefer to use a custom way, because I'm making a breakout game, and I want the player to be able to choose with precision the direction to give to the ball, hitting it more to left or to the right.

Thank you in advance for your help! smile
_________________________
Download my Breakout game, and compete in the online hi-scores! wink

Top
#199810 - 07/29/10 11:11 AM Re: Reverse vertical direction [Re: K1kk0z90]
Warmachine


Registered: 11/19/09
Posts: 203
this may or may not be of help to you since it is a bit off topic, but i had an issue with the parallaxer object going in the wrong direction on the y axis. when assigning your coordinates for the object(x,y) assign the y with a negative number. Example would be -20,-30. if that works just adjust the number until you find one that is to your liking. hope that helped! grin
_________________________
Developer/Composer : Vamprotector

Top
#199815 - 07/29/10 12:04 PM Re: Reverse vertical direction [Re: Warmachine]
clean_citrus


Registered: 03/23/10
Posts: 28
Here's what I came up with. You can easily tweak things to suit your taste and this way you can still use the bounce movement's features.
_________________________
"The future pivots around you"

Top
#199865 - 07/30/10 01:33 AM Re: Reverse vertical direction [Re: clean_citrus]
K1kk0z90


Registered: 07/29/10
Posts: 14
Loc: Italy
Thank you for your replies! smile
@clean_citrus: Thank you for your source file, it's a smart way to give the player more control over the ball. But I need something a little different: I want the ball, when it collides with the bat, to adjust its direction in base of where it collided on the bat. I mean, if the bat's sprite's width is 64, and the ball collides exactly in the center (32), it must go in the direction up (8). If it collides a bit on the right, for example 50, it must go on the right in a direction like 5, I don't know exactly.
In particular, I want the ball's direction to be a value between 3 and 13. My bat's sprite's width is 64, the ball's width is 16, and both have the action point in the center.
I thought of something like this:
direction = 3 + x

x : 11 = collision point : bat width
x = 11 * collision point / bat width

collision point = ball.x - bat.x + 32 (+32 because of the action point in the center)

So in the collision between ball and bat event, I added the action "Set direction to 3+11*(X( "Ball" )-X( "Bat" )+32)/64", but it doesn't work, because the ball always go on the right.

Could you help me again, please? Thank you very much for your help! smile
_________________________
Download my Breakout game, and compete in the online hi-scores! wink

Top
#199927 - 07/31/10 03:20 AM Re: Reverse vertical direction [Re: K1kk0z90]
dudeman129


Registered: 11/05/09
Posts: 26
First, make sure the hot spots are in the middle of the objects. If the bat's hot spot is on the far left, change X( "Bat" ) to X( "Bat" )+32.

Set direction to: (((X( "Ball" )-X( "Bat" ))*5)/32)+8

If that doesn't work, it's probably because MMF can't deal with floats in the middle of the expression evaluator. In that case, go (((X( "Ball" )-X( "Bat" ))+51)*5)/32

If that still doesn't work you may need to force it to a whole number: ((((X( "Ball" )-X( "Bat" ))*5)-(((X( "Ball" )-X( "Bat" ))*5) mod 32))/32)+8

Top
#199968 - 07/31/10 01:05 PM Re: Reverse vertical direction [Re: dudeman129]
RickyRombo


Registered: 03/05/08
Posts: 2521
Loc: Planet Earth
Set direction to: (((X( "Ball" )-X( "Bat" ))*5)/32)+8

should be

Set direction to: (((X( "Ball" )-X( "Bat" ))*5.0)/32.0)+8

if you want floats.
_________________________
AtomicPages by KetchupMaster - A must have for any web developer!

The Click Link

Top
#199977 - 07/31/10 02:40 PM Re: Reverse vertical direction [Re: RickyRombo]
dudeman129


Registered: 11/05/09
Posts: 26
You can just add a .0 if you want floats? I never knew that! laugh

Top
#199988 - 07/31/10 04:02 PM Re: Reverse vertical direction [Re: dudeman129]
RickyRombo


Registered: 03/05/08
Posts: 2521
Loc: Planet Earth
Well now you know wink

There's also some other stuff, such as division will come before multiplication
_________________________
AtomicPages by KetchupMaster - A must have for any web developer!

The Click Link

Top
#200013 - 08/01/10 02:30 AM Re: Reverse vertical direction [Re: RickyRombo]
K1kk0z90


Registered: 07/29/10
Posts: 14
Loc: Italy
Thank you very much! smile
Now it works.
_________________________
Download my Breakout game, and compete in the online hi-scores! wink

Top
#200033 - 08/01/10 08:56 AM Re: Reverse vertical direction [Re: K1kk0z90]
mojofltr


Registered: 10/13/06
Posts: 91
I have a silly, and probably less accurate way, to do this. Set your hotspot in the middle of your bat and have an event for the bat to ALWAYS look in the direction of the ball. Then on collision, change the direction of the ball to the direction of the bat. xD Silly, but it works in its own little way.

Top
Page 1 of 2 1 2 >


Site Links
Forum Index

Home Page
Online Store
Tutorials
Download Center
French Forum

Quick File Links
Multimedia Fusion 2
Updates - build 249
Standard Version
Developer Version

Extension Packs
Bonus Pack 1
Bonus Pack 2
z33z Extension Pack
LIJI Extension Pack

The Games Factory 2
Latest Update - build 249
Community Links
Fusion Wiki
MFA Repository
Klikdisc
The Daily Click
GameBuilder

GB Arcade
TDC Arcade
Madword

Extensions
Neatwares Extension List
Extension Updater

Lacewing & Moo Server
Klikfarm

Money from your games
Click Chat
9 People are chatting
Game Builder

Visit the GameBuilder Homepage

Recent Download

8-Bit Man

Latest News