A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Need help with simple sidescroller (super basic)

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Location
    none
    Posts
    14

    Need help with simple sidescroller (super basic)

    I've just started trying to put together the basics of a sidescroller (that's what I want to make, a game like Megaman) and I have a glitch that I need help with ironing out.


    My SWF is at http://www.joystickadventures.com/platforms.swf
    My FLA is at http://www.joystickadventures.com/platforms.fla
    The controls are right arrow to move right, left arrow to move left and space to jump.

    Basically my glitch is when you jump from the top platform to the bottom one, it doesn't register the hero ball on the right level, instead the ball is about 2 pixels above the bottom platform. It still acts like it is on the bottom platform but it really isn't.

    My second problem is being able to jump back up THROUGH the top platform which again will result in bad clipping.

    Basically I want these platforms like Mario, where you cannot jump through them and will always be perfect aligned with the top of them.

    Any help would be awesome. Also, if anyone knows any great tutorials on flash sidescroller games, I would be greatful. I've got most of the aspects down in my head, I just need to know how to make them.

    Again, thank you for helping me.
    .

  2. #2
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    Hi kerek,

    This is quite a common problem, don't worry. There are 2 big tutorials that i'll refer you to. They are based on "tile based" platform games ( which mario and sonic where ), but they have stuff in them ( like jumping ) that can be applied to "art based" things ( which is what your looks like ).

    Outside Of Society and
    Tonypa's Tile Based Games

    To get nice alignment with the platform when landing, you have to "look before you leap". See if you will hit the platform next time you move ( without actaully moving yet ). If you will hit, then you can work out the distance to the platform, and move exactly that distance, so you will end up on the platform ( but don't forget to then change downward speed to 0 ). That's the basics of it.

    As far as jumping up through pltforms, but no falling through them, then you have to only do the check if the vertical speed is < 0. If it is, then you will do the above, and stop on the platform, but if you're going upwards ( speed_vertical > 0 ) then you don't bother checking.

    Also, do a hitTest with the bottom of the player sprite, not the whole thing. Use the other form of the hitTest function. hitTest(x, y, true) ( look it up in help files for better description ).
    jonmack
    flash racer blog - advanced arcade racer development blog

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Location
    none
    Posts
    14
    aha!

    thanks a lot!
    .

  4. #4
    Junior Member
    Join Date
    Feb 2003
    Location
    none
    Posts
    14
    Do you know any tutorials that are more like seeing what you are making.
    Like how I have my platforms.swf and how when I am in the editor I dont just see AS but I have my character and platforms visibly there?

    I realize tiled based is a great way and I am doing these tutorials, but some stuff escapes me with this version, how would someone animate a character say jumping down at the start of the game? or say a cutscene or something?

    I'm a little confused.

    (like at the start of a game, the hero just doesnt appear, he would jump from the sky or walk onto the screen)


    EDIT: I just mean , these 2 tutorials seems very complex for what could be simplier. Maybe not? I'm just kind of lost and I'm not new to AS.
    Last edited by kerek; 12-05-2003 at 03:09 PM.
    .

  5. #5
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    Yeah, those tutorials are for proper tile-based games, but the jumping things and items etc can easily be applied in other types of games.

    As for effects like cutscenes, and intro animations. I'd concentrate on the main part of the game first before attempting "eye candy". But you could just simple have an animation ( or script ) to move the character onto the screen, then give control to the player only when it's in the right place.

    As for cutscenes, at the end of a level for example, you could remove player control, and then do a number of things. You could script something in, ie script the movement so as to emulate if the player was doing it. So the game would seamlessly go into the story. You can tell which games ( I'm thinking of really huge games like in c++ ) do this, becasue they use the "engine" to do the cutscenes, like gta3 if you know that. Or you could simply start playing a pre-done animation.

    There's many ways of doing it, but like I said, I wouldn't worry about things like that just quite yet

    As for art-based tutorials. I can't think of any tutorials about them right now, but a guy on here called leight was doing a open-source engine, which you could look at. The only problem, is if you're new to actionscript, jumping in the deep end at someone else code might not be the best thing to try first. Depends on how well you could cope. Sorry I can't find a link right now to that. I think he's got a link in his signature, and the thread was called something like "open source art based scroller". Hope that's a help.
    jonmack
    flash racer blog - advanced arcade racer development blog

  6. #6
    Junior Member
    Join Date
    Feb 2003
    Location
    none
    Posts
    14
    Im not new to AS , I have taken 2 FLash courses in my college.

    I would maybe be considered middle level intermidiate.
    When I go through these tutorials, I dont know what is going on.

    I understand what I need to do to make a game.
    Like for shooting you need to call the bullet, place it on the gun and change its x to go straight, if that bullet hits the enemy (which you test for) then the enemy MC would go to label "dead" or something.

    It's just these complex concepts are mind boggling me.

    Although I have made one with my approach at 'seeing what i am doing'

    it's here: http://www.joystickadventures.com/platforms.swf
    the fla is here: http://www.joystickadventures.com/platforms.fla

    I am having problems with this though, 1) I dont want the hero to be able to jump through the top platform from below. The hero should hit the bottom of the platform and fall down not go through. Also, if you go through the side of the platform, it does some whacko stuff and almost slides down through the platform

    Anyways, this is for a project that I have NEXT semester, but he is expecting a game like advanced concentration and I dont find that a good game to program, I want something I can be proud of, you know?

    So any help, would be awesome (and thanks for the help already)
    .

  7. #7
    Senior Member Kirill M.'s Avatar
    Join Date
    May 2002
    Location
    Toronto, Canada
    Posts
    712
    To make it stop going through a platform when jumping up, just do what you're doing to make him stop when he's falling and touching the platform, except test for this when the MC is moving up and on the top of the MC. Then your gravity function should make him fall.

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    code:

    onClipEvent (load) {
    ballheight = this._height;
    jumping = false;
    grav = 0.8;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    this._x += 5;
    }
    if (Key.isDown(Key.LEFT)) {
    this._x -= 5;
    }
    if (!jumping) {
    if (!_root.g1.hitTest(this._x, this._y+ballheight/2, true)) {
    if (!_root.g2.hitTest(this._x, this._y+ballheight/2, true)) {
    jumping = true;
    jumpingvel = 0;
    }
    }
    if (Key.isDown(Key.SPACE)) {
    jumpingvel = 10;
    jumping = true;
    }
    } else {
    lasty = this._y+ballheight/2;
    jumpingvel -= grav;
    if (jumpingvel<=-10) {
    jumpingvel = -10;
    }
    this._y -= jumpingvel;
    }
    if (_root.g1.hitTest(this._x, this._y+ballheight/2, true)) {
    this._y = _root.g1._y-(_root.g1._height/2)-(ballheight/2);
    jumping = false;
    }
    if (_root.g1.hitTest(this._x, this._y-ballheight/2, true)) {
    this._y = _root.g1._y+(_root.g1._height/2)+(ballheight/2);
    jumpingvel = 0;
    }
    if (_root.g2.hitTest(this._x, this._y+ballheight/2, true) && jumpingvel<0) {
    this._y = _root.g2._y-(_root.g2._height/2)-(ballheight/2);
    jumping = false;
    }
    if (_root.g2.hitTest(this._x, this._y-ballheight/2, true)) {
    this._y = _root.g2._y+(_root.g2._height/2)+(ballheight/2);
    jumpingvel = 0;
    }
    }


    You can probably see what happens, when you try to add more platforms?

    Yes, you will have to add hittest for each and every one of them. And thats going to be long code
    Last edited by tonypa; 12-05-2003 at 05:25 PM.

  9. #9
    Junior Member
    Join Date
    Feb 2003
    Location
    none
    Posts
    14
    yeah, but for learning sake, I think this is better for me.

    I dont mind waiting for my game to load, as long as while I code it I can see and tell what I am doing.

    I like your tutorials and spent a couple of hours on them earlier but some parts confuse me and some parts I just don't completely understand.

    It may be longer to do it this way, but at least I understand (err, well somewhat)


    EDIT: Sigh, I tried altering your code that you just posted to get rid of going through the platform sides and I am having no luck.

    These games will forever elude me!
    EDIT AGAIN: haha I found an awesome glitch in your code, but it's not bad, like it would be but if you think about it, it would make an awesome addition to put on like gravity boots or something
    First off I moved this outside the if notjumping loop and added a condition so people can't multi jump.
    code:
    	if (Key.isDown(Key.SPACE) && !jumping) {
    jumpingvel = 10;
    jumping = true;
    }



    Now thing is, take away the && ! jumping from that first if condition.
    Now run the movie and first notice you can jump multiple times (good for double jump boots lets say) and then drop to the bottom platform.... now go under the top platform and jump so you hit the bottom of the top platform and hold the jump button - you stick! As long as you hold down space, you can stick to the bottom of the platform and even shoot yourself up from the sides. hehe
    Pretty cool and would be a cool feature for a secret pair of boots in say a Megaman game or something, huh?

    But alas, let me not get ahead of myself here. Let me continue to learn the basics so I can make these great ideas in my head into games!

    This is the kind of game I want to end up making:
    http://www.dzarchive.com/iragination/clips/games.php
    Launch the second game. The first game is my ultimate goal, but obviously the first is not as advanced. Except for the badguy bouncing off the walls, but basically I want to be able to walk, shoot, jump and jump on platforms and maybe fight a couple badguys. The thing is I want to learn how, not use other peoples codes because I don't know what to do.
    Last edited by kerek; 12-05-2003 at 06:23 PM.
    .

  10. #10
    avatar free
    Join Date
    Jul 2002
    Location
    UK
    Posts
    835
    Originally posted by kerek
    Im not new to AS , ...I would maybe be considered middle level intermidiate.

    ...

    1) I dont want the hero to be able to jump through the top platform from below.
    Lol, oh man did i completely misread everything you said or what?! When you said "I'm just kind of lost..." I just assumed that the rest said "and I'm new to AS". So sorry for that. And you didn't want to the hero to go through the platforms when jumping upwards! Completely off the ball today.

    So if the hero is moving upwards ( ie jumping ) check the top side of the movieclip against the platforms. If it will hit next frame, move it so it just touched - and set the vertical velocity to 0 ( to get rid of bumping the roof several times ). If it's going downwards ( ie falling ) then check the bottom of the hero with platforms for the next frame. Again, if it will hit, move it so it just touches, then set velocity to 0.

    As for side on movement, well, you guessed it. Check the correct side that will hit, from the direction of the movement. Sounds pretty easy when you say it like that!

    In fact, seeing as this is just a learning example, you could get away with not checking which to check, and just check all of edges at once. getBounds() is good for that.

    "But alas, let me not get ahead of myself here. Let me continue to learn the basics so I can make these great ideas in my head into games!" - good attitude. Games are the hardest thing to make in any language ( to quote a big ol' softy in these parts ). "walk before you can run" and all that. I learned that the hard way with dreams of over ambitious games. And still paying the consequences - 0 proper games to data

    I like that game link you sent. It looks like they've used scripted "cutscenes" in that. You suddenly have no control over the character, and it does stuff, then you get control back again. It's a cool way of doing it.
    jonmack
    flash racer blog - advanced arcade racer development blog

  11. #11
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    or you can take a look at marmotte's, or my open source and use that (if u want, but u might wana make your own stuff like i do)

    marmotte's platform engine is literally pizil perfect, but doesnt have the top hitTest yet (I'm sure it wouldnt be that hard to put it in)
    my platform engine (if its a big level click on 'Optimised art based scrolling') isnt as perfect hitTest, but it has top hitTest with scrolling too.


    http://www.gotoandplay.it/_articles/

    hope it helps mate

  12. #12
    Vox adityadennis's Avatar
    Join Date
    Apr 2001
    Posts
    751
    Baukareg made a really good engine too, it just needs a couple changes to make it scroll. It's really similar to Leights I think, but here it is:
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center