HOME | DD

JohnJensen β€” Shooter Engine AS3 by-nc-nd

Published: 2009-01-13 22:11:21 +0000 UTC; Views: 8479; Favourites: 25; Downloads: 373
Redirect to original
Description WAIT FOR IT TO LOAD >:C

Platformer + Shooter c:

Controls
Arrow keys - move
Up - Jump
Mouse - Aim
Click - Shoot

To jump up a wall, stand next to it, and hold down right/left arrow key, while pressing Up (jump button)!

To reload, put the mouse over the player.

The level is generated from a multidimensional array. So the level is tile based, but the game isn't.

Enjoy the engine.

REMEMBER, THIS IS AN ENGINE, NOT A GAME.

Bugs
- You can get stuck in some walls
- You can jump through the roof at the right-top corner

I'll fix those if I make this into a real game.

I also discovered Flash CS4 had a Sound libary, so I added some sounds from there to the game.

Thanks to ~AceDecade for giving me tips, and tutoring me a little about AS3, and encouraging me to learn it.
Related content
Comments: 89

mine22mine [2012-04-10 11:51:02 +0000 UTC]

This is Awesome!..

I wish I am as good as you in creating games in AS3..lol..I'm just starting to create my first platformer and now i'm stuck with figuring out how to shoot projectiles.. >_<" haha..

πŸ‘: 0 ⏩: 0

MC117db [2012-01-12 04:26:48 +0000 UTC]

Is it possible you can release the fla. file? I am interested in the wall-jumping mechanics

πŸ‘: 0 ⏩: 1

JohnJensen In reply to MC117db [2012-01-18 14:37:19 +0000 UTC]

I'm not really comfortable with sharing my .fla file, but I can tell how I programmed the mechanics.

Basically whenever you're touching a wall, I'm checking if the user is holding down the jump button at the same time, and then I make him jump (usually setting the gravity/y velocity variable to a negative numbers in my game programming method) and then I set the x velocity variable to a number that corresponds to the side the player is touching the wall: If the player touches a left wall, set x vel to 5, and if a right wall then x vel to -5, and y vel to -10. You can change those numbers until it feels right, those were just some I randomly came up with.

Hope it sorta gives you an idea of how it works.

πŸ‘: 0 ⏩: 1

MC117db In reply to JohnJensen [2012-01-19 04:29:02 +0000 UTC]

Thank you, that has been really helpful. Just wondering, did you set separate hitboxes for each side of the the walls to check whether the player hits the left or right side of the walls? Or did you check for the current direction the player is heading when it touches the wall (check whether x vel is += or -= etc).

πŸ‘: 0 ⏩: 1

JohnJensen In reply to MC117db [2012-01-19 12:31:39 +0000 UTC]

I always use the same movie clip for ground, so I always have different sides of the player checking for collisions on the ground. If I have a 20x20 ball as a player, I'd say (assuming the anchor point is in the middle) if(level.hitTestPoint(player.x-10, player.y, true)) to check the left wall and then player.x+10 for right wall, player.y+10 for ground and player.y-10 for ceiling.

Also another technique I usually use, is having a while() function for each of the sides, for example if the player is 4 pixels inside the wall, and is only pushed 1 pixel away for each frame it'd look weird like in this Flash, so I have a code like this for each side:

while(level.hitTestPoint(player.x-10, player.y, true))
{
player.x++;
}

so it basically keeps pushing him to the opposite side until he's not touching the wall any longer. I usually put the code after the first collision checks.

πŸ‘: 0 ⏩: 1

MC117db In reply to JohnJensen [2012-01-20 08:57:19 +0000 UTC]

I see you got the level wall to check for collisions. Didn't cross my mind that you could assign the hitTest responsibility to the level walls. Thanks for sharing , I look forward to your future works.

πŸ‘: 0 ⏩: 0

KimBo007 [2011-03-28 13:51:37 +0000 UTC]

any usefull tutorials for making this kind of things?? dont like wall jumping tho

πŸ‘: 0 ⏩: 1

JohnJensen In reply to KimBo007 [2011-04-02 14:23:16 +0000 UTC]

Look in my gallery for a platformer tutorial.

πŸ‘: 0 ⏩: 0

HampoArgent [2010-11-16 07:38:47 +0000 UTC]

I'm working with a tile engine at the moment to, trying to upgrade it to AS3.0 from AS1. It's more of a platformer/parkour engine but if you'd like to swap codes or something, let me know.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to HampoArgent [2010-11-17 16:45:50 +0000 UTC]

heh, to be honest with you only the level generated was tilebased, the collision was done with hitTestPoint() onto the wall movieclip. I just used a map to place everything...

πŸ‘: 0 ⏩: 1

HampoArgent In reply to JohnJensen [2010-11-17 17:43:40 +0000 UTC]

Ah, I use a prefeined array, with each different number spawning a different map piece. Still working the kinks out of it though

πŸ‘: 0 ⏩: 1

JohnJensen In reply to HampoArgent [2010-11-23 16:01:35 +0000 UTC]

yup, that's what you do ;)

πŸ‘: 0 ⏩: 0

Eyaare [2010-04-11 16:21:12 +0000 UTC]

IDK if someone's said it, but I assume ammo is AMMO IN CLIP/OTHER AMMO. So you have to make if
if(OTHER AMMO <= 0) {
}
Else if (OTHER AMMO <= 0){
reload;
}

Wasn't mean to be an actual code, just a concepty-thing.

Also, yes, as has been said before, WASD controls.

And, finally, you should definitely do a tutorial, or upload the .fla, or something, preferably the tutorial one. So few of those exist for AS3 >.<

But nice work.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Eyaare [2010-04-12 09:46:25 +0000 UTC]

The ammo bug is fixed in the actual .fla

WASD controls has also been added in actual .fla

Haha, the .fla is probably really confusing, cause I animated everything with codes aswell, so I'm not sure how much help it would be.

It's probably just a better idea to learn how to port from AS2 to AS3.

Like if you see

onEnterFrame = function() {
Β Β Β _root.player._x += 5;
};

it would be

function enterFrame(e:Event):void {
Β Β Β player.x += 5;
}

stage.addEventListener(Event.ENTER_FRAME, enterFrame);

in AS3.

Writing AS3 is a tad bit longer than 2, but it's WAY more flexible, and it's 10x faster!

But one thing you can't do in AS3 is write the code on the movie clip, which you might think is bad in the start, but you'll get used to write the entire code on the frame.

πŸ‘: 0 ⏩: 1

Eyaare In reply to JohnJensen [2010-05-10 20:53:18 +0000 UTC]

Yes, but you see, my problem lies in a lack of knowledge of AS2. I get things like hittest, variables, basic movement and such but utilizing the mouse, setting angles and gravity I never could figure out.

UGH. It's very frustrating because I'm working on an identical game. We finally figured we'd try something somewhat different, though, but for the longest time a basic game engine had been holding us back.

πŸ‘: 0 ⏩: 0

Jusey1 [2010-01-07 00:08:46 +0000 UTC]

Is there a actually game of this? Cause I was hoping for something to kill.

πŸ‘: 0 ⏩: 0

WEEGEEXD [2009-11-08 12:44:54 +0000 UTC]

nice! you should totally make a game of it!

πŸ‘: 0 ⏩: 0

Ninjapear [2009-10-09 20:03:30 +0000 UTC]

hey if this is a engine how do i download it into my flash???

πŸ‘: 0 ⏩: 0

Narusim1 [2009-06-23 23:12:34 +0000 UTC]

Whats the script for shooting?

πŸ‘: 0 ⏩: 0

PalePhail [2009-06-23 21:49:42 +0000 UTC]

IM trying to make a platformer where one of the characters attacks is to shoot this energy ball. there's no aiming involved it just goes in whatever direction he's facing. what would be the code for that? please help me as2 is what im programming in

πŸ‘: 0 ⏩: 0

bonniegayle [2009-06-21 22:29:56 +0000 UTC]

I started with 8/55 bullets. Next load was 7/56.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to bonniegayle [2009-06-22 08:43:42 +0000 UTC]

It's fixed in the real version.

πŸ‘: 0 ⏩: 0

MrSlowNiko [2009-06-07 21:45:25 +0000 UTC]

i had 2/0

πŸ‘: 0 ⏩: 1

JohnJensen In reply to MrSlowNiko [2009-08-02 09:33:08 +0000 UTC]

All bugs in this engine are fixed in the real game.

πŸ‘: 0 ⏩: 1

MrSlowNiko In reply to JohnJensen [2009-08-04 04:07:34 +0000 UTC]

πŸ‘: 0 ⏩: 0

Dark-Helmet1 [2009-03-28 11:04:27 +0000 UTC]

Btw I added this as my first Fave

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Dark-Helmet1 [2009-03-28 22:07:19 +0000 UTC]

πŸ‘: 0 ⏩: 0

Dark-Helmet1 [2009-03-28 11:03:54 +0000 UTC]

OMG!!! So... friggen... awesome... Dude you gotta teach me that kind-o AS3, cuz its simply AWESOME

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Dark-Helmet1 [2009-03-28 22:08:10 +0000 UTC]

Well, you could've done it with AS2 but.. yeah. xD

Do you have MSN or something? I could maybe tutor you a bit?

πŸ‘: 0 ⏩: 1

Dark-Helmet1 In reply to JohnJensen [2009-03-29 12:42:08 +0000 UTC]

Sent your note back. take a look at it.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Dark-Helmet1 [2009-03-29 14:55:26 +0000 UTC]

added your MSN C:

πŸ‘: 0 ⏩: 1

Dark-Helmet1 In reply to JohnJensen [2009-03-29 15:26:05 +0000 UTC]

Can you note me yours too. I didn't really notice it -.-

πŸ‘: 0 ⏩: 0

asikka [2009-02-24 19:01:59 +0000 UTC]

are there supposed to be enemies or something cuz all iv got is me and a lot of floating blocks....

πŸ‘: 0 ⏩: 1

JohnJensen In reply to asikka [2009-08-02 09:33:35 +0000 UTC]

There's gonna be enemies in the real game.

πŸ‘: 0 ⏩: 1

asikka In reply to JohnJensen [2009-08-03 12:36:19 +0000 UTC]

O rly?

πŸ‘: 0 ⏩: 0

Rexus64 [2009-01-26 02:09:02 +0000 UTC]

I completely ran out of bullets...but its soo fun!(^-^)

πŸ‘: 0 ⏩: 1

JohnJensen In reply to Rexus64 [2009-08-02 09:33:50 +0000 UTC]

Thanks.

Just reload if you want to play again then!

πŸ‘: 0 ⏩: 0

minibc [2009-01-18 00:57:34 +0000 UTC]

whoa that's awesome john! I'm trying AS3 also, but it's way harder than AS2. most i got was a little guy that could jump around

btw.. is it possible to draw the level in AS3 like in your previous tutorials? or does the level have to be created using an array?

πŸ‘: 0 ⏩: 1

JohnJensen In reply to minibc [2009-01-18 15:26:38 +0000 UTC]

of course you can draw your levels, I just get lazy at games when I have to draw the ground, so I made the level using an array.

πŸ‘: 0 ⏩: 1

minibc In reply to JohnJensen [2009-01-18 16:47:03 +0000 UTC]

ok good. i was getting worried cuz i'm not very good at arrays yet

πŸ‘: 0 ⏩: 2

JohnJensen In reply to minibc [2009-01-18 22:04:53 +0000 UTC]

A level array could be like this:

myLevel = [
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 1, 1, 0],
[0, 0, 0, 0, 0]
];

for(var i = 0; i < myLevel.length; i++) {
for(var j = 0; j < myLevel[i].length; j++) {
if(myLevel[i][j] == 0) { /* Wall */ }
if(myLevel[i][j] == 1) { /* Free space */ }
}
}

Could also use a switch() {} instead of the ifs.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to JohnJensen [2009-01-18 22:05:23 +0000 UTC]

don't forget var before myLevel. xD

πŸ‘: 0 ⏩: 0

JohnJensen In reply to minibc [2009-01-18 22:02:31 +0000 UTC]

XD They're quite easy.

var myArray:Array = new Array("Peter", "Bob", "Larry");

trace(myArray[0]); // Peter

var _random:Number = Math.floor(Math.random()*myArray.length);
trace(myArray[_random]); // A random string from the array.

/* AS3 doesn't have AS2's random(), you have to use Math.floor()
Math.random()*number like in JavaScript. Quite sad.

for(var i = 0; i < myArray.length; i++) {
trace(myArray[i]);
}
// Peter Bob Larry

πŸ‘: 0 ⏩: 0

blueninja12 [2009-01-16 01:21:07 +0000 UTC]

You make this into a game!

πŸ‘: 0 ⏩: 1

JohnJensen In reply to blueninja12 [2009-01-18 22:09:55 +0000 UTC]

indeed!

πŸ‘: 0 ⏩: 1

blueninja12 In reply to JohnJensen [2009-01-19 03:57:23 +0000 UTC]

...AND ADD SOME ENEMIES IF YOU DO. AND GIVE IT A HALF LIFE CONCEPT.

πŸ‘: 0 ⏩: 1

JohnJensen In reply to blueninja12 [2009-01-19 13:43:54 +0000 UTC]

No GoldenEye 64 concept

πŸ‘: 0 ⏩: 1

blueninja12 In reply to JohnJensen [2009-01-19 19:01:46 +0000 UTC]

WHY NOT HALF LIFE YOU CAN ADD MISSIONS

ALSO ADD ACHIEVEMENTS

πŸ‘: 0 ⏩: 0

snapel [2009-01-15 13:52:57 +0000 UTC]

Neat. Now it only needs good idea for it ; )

πŸ‘: 0 ⏩: 1

JohnJensen In reply to snapel [2009-01-15 16:14:36 +0000 UTC]

Thanks

πŸ‘: 0 ⏩: 0


| Next =>