Fun-Motion Physics Games Forum  

Go Back   Fun-Motion Physics Games Forum > Developers > Feedback Request

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-06-2007, 01:08 PM
genericuser genericuser is offline
Junior Member
 
Join Date: Mar 2007
Default A small Flash game/toy: Building demolition

I found a tutorial for a small gravity engine in Flash, tinkered a bit with it(added horizontal motion), and made this small toy/pointless game.

Enjoy!

Building Demolition

Please post ideas and comments.
Reply With Quote
  #2  
Old 03-06-2007, 06:01 PM
Jokker's Avatar
Jokker Jokker is offline
Senior Member
 
Join Date: Feb 2007
Location: Hell, Romania
Default

Actually it's not all that bad. The movement is a bit clunky, but it's not like you spent hours on optimizing, so it works.

What would have been better, would have been disabling gravity once the bomb exploded, and maybe adding mouse control.

Overall, it's above average, and pretty good provided you added horizontal motion yourself.

How much time did you spend on it?
Reply With Quote
  #3  
Old 03-06-2007, 09:01 PM
Rob223's Avatar
Rob223 Rob223 is offline
Senior Member
 
Join Date: Mar 2007
Location: INSIDE YOUR MIND
Default

M...m...m... Mouse control.

What did I just say?
Reply With Quote
  #4  
Old 03-07-2007, 07:32 AM
genericuser genericuser is offline
Junior Member
 
Join Date: Mar 2007
Default

Quote:
Originally Posted by Jokker View Post
Actually it's not all that bad. The movement is a bit clunky, but it's not like you spent hours on optimizing, so it works.

What would have been better, would have been disabling gravity once the bomb exploded, and maybe adding mouse control.

Overall, it's above average, and pretty good provided you added horizontal motion yourself.

How much time did you spend on it?
One hour, mostly tinkering with different options and buildings.

Last edited by genericuser; 03-07-2007 at 07:41 AM.. Reason: Fixed estimate
Reply With Quote
  #5  
Old 03-07-2007, 08:01 AM
Jokker's Avatar
Jokker Jokker is offline
Senior Member
 
Join Date: Feb 2007
Location: Hell, Romania
Default

Well, it's pretty good for just one hour. Like I said, disable the gravity for exploding bombs, mouse control, bouncing off walls and it'd be a neat game to waste 2 minutes on.


EDIT: Mind sharing the tutorial? I got an hour to waste as well. =D
Reply With Quote
  #6  
Old 03-07-2007, 02:09 PM
Dj Demetrius's Avatar
Dj Demetrius Dj Demetrius is offline
Senior Member
 
Join Date: Feb 2007
Location: Sweden
Post

I want to learn how to make games too..
Reply With Quote
  #7  
Old 03-07-2007, 02:14 PM
mister.x's Avatar
mister.x mister.x is offline
Senior Member
 
Join Date: Feb 2007
Location: Finland
Default

I didnt like it why is it so good ???
Reply With Quote
  #8  
Old 03-07-2007, 08:37 PM
genericuser genericuser is offline
Junior Member
 
Join Date: Mar 2007
Default

Quote:
Originally Posted by Jokker View Post
Well, it's pretty good for just one hour. Like I said, disable the gravity for exploding bombs, mouse control, bouncing off walls and it'd be a neat game to waste 2 minutes on.


EDIT: Mind sharing the tutorial? I got an hour to waste as well. =D
Sure!
Code:
Make an MC of a ball and a platform. 
Call the platform's instance "floor". 
Apply this code to the ball MC:

onClipEvent(load){
velocity = 0
gravity = 2
friction = 0.01
}
onClipEvent(enterFrame){
velocity += gravity
velocity -= friction*velocity
_y += velocity
if(_y>_root.floor._y){
_y = _root.floor._y
velocity *= -0.9
}
}

(Make sure you place the ball over the platform 
because it is the platform which makes it bounce)


I'll post my version later. Have to fix some code.

Stupid question: By mouse control, do you mean being able to place the bomb before dropping it?
Reply With Quote
  #9  
Old 03-08-2007, 07:07 AM
genericuser genericuser is offline
Junior Member
 
Join Date: Mar 2007
Default

The code for my gravity engine:
Code:
//My (maybe not-so)simple gravity engine, now capable of horizontal motion

//Made by "genericuser", based on the gravity engine from GinjaNinja

onClipEvent(load){ //set variables
velocity = 0 //intially, the bomb doesn't go up or down
gravity = 2 //set gravity here
friction = 0.01 //vertical friction
horizontalfriction = 0.03 //horizontal friction??? stops the bomb gradually
horizontalvelocity = 3.5 //starting speed of the bomb
}
onClipEvent(enterFrame){
velocity += gravity //GinjaNinjas code
velocity -= friction*velocity 
if (horizontalvelocity > 0.1){ //small hack needed to fix a problem
horizontalvelocity -= horizontalfriction //slow down the bomb
}
_y += velocity
_x += horizontalvelocity //the ACTUAL horizontal movement
if(_y>_root.floor._y){ //if the bomb hits the floor, bounce
_y = _root.floor._y
velocity *= -0.9
}
}
BTW, I fixed the problem with bouncing explosions. When I add the other suggestions from Jokker, i'll upload it.
Reply With Quote
  #10  
Old 03-08-2007, 08:30 AM
Jokker's Avatar
Jokker Jokker is offline
Senior Member
 
Join Date: Feb 2007
Location: Hell, Romania
Default

By mouse control, I mean that you do this:

When mouse_x and mouse_y (forget the variable names, but meh =\) are in the ball and a mouse button is pressed, gravity and everything disables, and the ball moves with the mouse. During that time, you calculate x_speed and y_speed using x_speed= x_ball - x_ball_last_frame, and when you let go of the mouse button, the speed remains in the program, and the ball continues to go, like inertia.

PS. make it bounce off the walls so you can actually see if it's going well.


Oh, and I'll try to optimize the original program and add my own stuff into it...once I get a Flash Player installed and ready to test... =\
Reply With Quote
  #11  
Old 03-08-2007, 03:04 PM
SataMaxx's Avatar
SataMaxx SataMaxx is offline
Senior Member
 
Join Date: Mar 2007
Location: Nancy, France
Default

Well in fact just adding instantaneous speed to positions to get the new coordinates gets you to wrong results, and you'll see it if you want to use *real* formulas and values for gravity, or make objects interact with each other (such as a gravitational system with more than two objects, or objects connected by springs).
To really simulate physics, you need to get the real differential equations that define the movement, and calculate the next step value for each variable (speed, acceleration, damping....) with some kind of algorythm. Simply calculating the following step by adding values will lead you to results totally different that what expected. One of the calculation method for solving numerically the differential equations is called the Runge-Kutta algorythm, and to my own expereince it's quite accurate and powerful.
If you want some examples for using it (such as movement under gravity and damping, or spring movement, or whatever...), I'll be glad to post some links and generic code.
Reply With Quote
  #12  
Old 03-08-2007, 06:16 PM
Jokker's Avatar
Jokker Jokker is offline
Senior Member
 
Join Date: Feb 2007
Location: Hell, Romania
Default

That'd be great if you could. Though well...my main problem is...well...I don't really understand the basics of C++ or other languages. Not as in syntax or stuff. But how to SET UP the COMPILER. I can't make Bloodshev C++ even run a bit of Hello World code, because I don't know what type of file to create..

So yeah...

PS. What...do you write Flash in? Macromedia (I think it's Adobe now, but meh) Flash ...something. I can't recall the name...
Reply With Quote
  #13  
Old 03-08-2007, 06:31 PM
Dj Demetrius's Avatar
Dj Demetrius Dj Demetrius is offline
Senior Member
 
Join Date: Feb 2007
Location: Sweden
Smile

I didn't understand much of that code there, but you guys really got some talent. Keep that up and you'll (probably) be great game developers some day, creating Cortex Command 2, and a new better Toribash!
Reply With Quote
  #14  
Old 03-08-2007, 07:13 PM
SataMaxx's Avatar
SataMaxx SataMaxx is offline
Senior Member
 
Join Date: Mar 2007
Location: Nancy, France
Default

If you don't know how to code I presume it's a bit useless to post complicated programming stuffs here. But I can already give you one very good link : http://www.myphysicslab.com/
On this site are some very basic-physic toys in java, the explanation of the physics behind them, and some explanations on how to program them, but not full, you'll have to figure out some things by yourself...
@jokker : we could meet sometime on irc or whatever so that I help you configuring dev-c++

Now if someone (really) knows how to program, and wants some help with physics I can help with code or explanations....
Reply With Quote
  #15  
Old 03-10-2007, 11:55 PM
VinceA VinceA is offline
Junior Member
 
Join Date: Mar 2007
Location: Copenhagen
Default AS3 written in Flex from Adobe

Quote:
PS. What...do you write Flash in? Macromedia (I think it's Adobe now, but meh) Flash ...something. I can't recall the name...
Well you can write your action script 3 code in Flex. Works very nice! The new AS3 is faster than AS2 but still struggles with bitmaps. Not ideal for a fullscreen scroller..

For more on that: http://www.cove.org/ape/
Reply With Quote
  #16  
Old 04-11-2007, 10:07 AM
fusion1224's Avatar
fusion1224 fusion1224 is offline
Member
 
Join Date: Apr 2007
Location: Australia
Default

Quote:
To really simulate physics, you need to get the real differential equations that define the movement, and calculate the next step value for each variable (speed, acceleration, damping....) with some kind of algorythm.
To calculate physics properly you need to introduce a timestep, which allows the path of a physically simulated object to be calculated over time.
I use Verlet integration for calculating physics simulations. There are many flash physics demos out there that use Verlet, for example the Ape physics engine mentioned in the last post.

This is a great paper on Verlet which goes into detail without getting too complicated:
http://www.teknikus.dk/tj/gdc2001.htm
Reply With Quote
  #17  
Old 07-22-2007, 10:40 PM
OkumTheLostNinja's Avatar
OkumTheLostNinja OkumTheLostNinja is offline
Senior Member
 
Join Date: Jun 2007
Location: There.
Default

Quote:
Originally Posted by Jokker View Post
What would have been better, would have been disabling gravity once the bomb exploded
i agree i dont like when those part of the buildings fly up
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.