00:00
00:00
Newgrounds Background Image Theme

Schwicky just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Platformer physics/game Tutorial?

1,149 Views | 3 Replies
New Topic Respond to this Topic

Platformer physics/game Tutorial? 2013-10-29 19:16:48


I have done a ton of tutorials and read many AS3 books trying to jump from animator/designer to AS3 programmer and it's been a nightmare finding a good source to make a decent AS3 platformer. There's numerous tutorials for basic ones, but all tuck the code on one class and have limited functionality. I'm really looking for a solid link tutorial, book, or simply theory on how to make one. My goals are to construct one that: is multi-leveled, uses a physics class that can apply to multiple objects (player, enemies, etc...), can do slope hitTestPoint/shapeflag.

As of right now I can code on one main class the physics and state changes for my player (gravity, surface collision, jump, etc...), but I don't really know how to separate all those physics and object collision into a class I can apply to multiple objects. I want to have enemies and objects also have those same physics applied and I prefer to do it with classes and not a cluttered system of functions on one file. A simple walk thru on theory or a basic write up of bare minimum OOP physics class for multiple Objects would really help . I'm trying to pretty much have all the functionality of a basic Megaman game, but with slope collisions on surfaces.

I understand a fair amount of AS3, but I struggle with OOP on this scale and every tutorial feels like either day 1 stuff or using a preconstructed physics engine to do all the work for you. I'm willing to buy books or do pay sites provided these will really help me break into designing games beyond the usual google finds for simple games.

Response to Platformer physics/game Tutorial? 2013-10-29 19:24:11


When I was a dumb kid, tutorials from Internet were more than enough for me to figure out more complex stuff on my own.
Somehow I also had pretty good understanding of math, algebra, geometry and physics, despite being an overall dumb and impatient kiddo.
About learning OOP from books, I can't help you with that, I didn't study any OOP-themed books myself. But I learned quite a lot of OOP techniques by just sitting on these very forums. There are some basics related to how classes work, knowing which you can later figure out complex stuff on your own.
Including how to make a physics engine apply to all kinds of game objects. (That's done through extension & helper classes, but some people like PSvils will probably suggest component-behavior system, which I'm not even sure how to apply here)

Response to Platformer physics/game Tutorial? 2013-10-29 19:51:45


There's tons and tons of platformer engines / frameworks out there. You don't have to reinvent the wheel. If your goal simply is to make a platformer you should use an engine.

If your goal is to figure it all out for yourself you shouldn't need tutorials.

Response to Platformer physics/game Tutorial? 2013-10-29 19:56:26


At 10/29/13 07:16 PM, FlashDeviant wrote: I understand a fair amount of AS3, but I struggle with OOP on this scale and every tutorial feels like either day 1 stuff or using a preconstructed physics engine to do all the work for you. I'm willing to buy books or do pay sites provided these will really help me break into designing games beyond the usual google finds for simple games.

Platformers are awful to start out with btw, they're rather complex. You can use a physics engine like nape, but that's probably overkill.

Here's how to organize it:

Entity: this is the base class, it has x, y, velocity, rotation, hasJumped, etc. Every physics-able thing in your game would extend this. You would somehow describe a collision object: a rectangle, circle, whatever.

Dude: maybe this is your player/enemy class. In addition to Entity's physics stuff, you might also have hit points and damage or something. Entities that aren't also a Dude would be physics-able things without hit points, like a box you can move.

You'd stick all the Entities in an array, loop through the array, and check each one. You can give the Entity class an "update" method where you handle internal physics, like adding velocity to position. You would check for collisions here.

More stuff.

Just play around with coding, platformers suck and you won't get it right in a short amount of time.