Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 10-03-2009, 12:30 PM   #1
RiezaHughes
Student at Abertay
Location in the middle of no-where ;D

Posts 5
Afrostyle [Flash8] Platformer Gravity Problems.

Hi Kirupa, first time poster here... and i hope i can help out other folk on the forums as well as just asking for a little help here and there ^^

I have been asked to create a Flash game for my student project this year. i chose to create a 2D platformer. Now, the first thing i did was look at your tutorial on gravity, however when i looked at it i realised it was slightly different from what i wanted so i tweaked it a little using information from http://www.bit-101.com/tutorials/gravity.html.

I got it to jump exactly the way i wanted it to, however then i wanted it to land on platforms... and theres where i hit the snag.

First i created a single platform at the bottom of the stage so that the ball would land on it after jumping instead of falling right past the boundaries of the stage. This worked, however the ball always landed at different depths into the ground... which i thought was stange. Nevertheless i ignored it for the moment and thought about making more than one platform to get the ball landing on more than one thing. however, no matter what i tried, i could only get it to land on one. I have no idea what i'm doing wrong. all the hit states are correct.. all the instance names and code are exactly the same on the stage however, so even though its the same as the first time it landed, i think it's conflicting and causing screwups..

In the file attatched, you'll find that the ball only lands on the right hand panel. I've tried everything i could think of and can't get the ball to land on the other panels. The code is exactly the same...

if anyone can help me i would really appreciate it. Thanks.

Left and right to move. Space to jump
Attached Files
File Type: fla gravity18.fla (37.0 KB, 6 views)
RiezaHughes is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 10-03-2009, 01:12 PM   #2
Ph03nix
Registered User
 
Ph03nix's Avatar
I looked at your code and general game structure, and I hate to sound rude but it's quite amateurishly made. Although flash supports "hitTests", they are inaccurate unless your object's and the platform's edge positions are always rounded to the nearest decimal. The ideal way to program a platformer game is not to use hitTests, but rather to create an two-dimensional array of integers, with values representing things like square blocks. If you're interested in my approach I wouldn't mind making a simple example of the basic platforming game, but I should warn you it would use object-oriented design, which you might not be familiar with.
Ph03nix is offline   Reply With Quote
Old 10-03-2009, 01:14 PM   #3
RiezaHughes
Student at Abertay
Location in the middle of no-where ;D

Posts 5
Quote:
Originally Posted by Ph03nix View Post
I looked at your code and general game structure, and I hate to sound rude but it's quite amateurishly made. Although flash supports "hitTests", they are inaccurate unless your object's and the platform's edge positions are always rounded to the nearest decimal. The ideal way to program a platformer game is not to use hitTests, but rather to create an two-dimensional array of integers, with values representing things like square blocks. If you're interested in my approach I wouldn't mind making a simple example of the basic platforming game, but I should warn you it would use object-oriented design, which you might not be familiar with.

it's not rude, don't worry. i'm still learning. ^^

and i would be... Anything to help me get along It might turn out to be a better way to make the game. i'm all about learning.
RiezaHughes is offline   Reply With Quote
Old 10-03-2009, 01:18 PM   #4
Ph03nix
Registered User
 
Ph03nix's Avatar
Quote:
Originally Posted by RiezaHughes View Post
it's not rude, don't worry. i'm still learning. ^^

and i would be... Anything to help me get along It might turn out to be a better way to make the game. i'm all about learning.
That's a very good approach! I'll whip up a simple platformer ASAP, and I'll keep the number of classes low (one for characters, and maps (levels) should be all I need)

I'll also try to document my code to make it easy to understand.
Ph03nix is offline   Reply With Quote
Old 10-03-2009, 01:19 PM   #5
RiezaHughes
Student at Abertay
Location in the middle of no-where ;D

Posts 5
Quote:
Originally Posted by Ph03nix View Post
That's a very good approach! I'll whip up a simple platformer ASAP, and I'll keep the number of classes low (one for characters, and maps (levels) should be all I need)

I'll also try to document my code to make it easy to understand.

okay. i appreciate this. Thank you very much.

if it's easier, feel free to add me via my email to msn.
RiezaHughes is offline   Reply With Quote
Old 10-03-2009, 02:51 PM   #6
Ph03nix
Registered User
 
Ph03nix's Avatar
Ok, here's the platformer sample

The concept is that it contains a two dimensional array called map. The game draws the map by creating 16x16 tiles that represent values of the array. Character check their positions based on the array to see if they are touching the walls or not.

I tried to document it as much as possible.

Enjoy!
Attached Files
File Type: zip Platformer.zip (21.6 KB, 11 views)
Ph03nix is offline   Reply With Quote
Old 10-03-2009, 03:43 PM   #7
RiezaHughes
Student at Abertay
Location in the middle of no-where ;D

Posts 5
thank you very much. i'm seen this being done before, and i couldn't make sense of it. but this definately breaks it down a lot more. I appreciate you taking the time to do this. ^^
RiezaHughes is offline   Reply With Quote
Reply

Tags
flash, gravity, platforms


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 -4. The time now is 06:29 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com