A platform game

Need programming help? Want to post programming tips? Are you programming a game and want to show it off? That and more here.

A platform game

Postby Konradix » May 12th, 2010, 10:01 am

So I want to make platform game. I've done hero walking, idle and jumping from both sides, but how do I make it walk, and change sprite when I turn (when I'm walking to left then it uses left sprite walking, but when im walking to right its not flipping horizontal, its changing left walking to right.).
"Men cry not for themselves, but for their comrades"

Check out my newest level called:
Image
Be sure to leave a comment and a rating ;)
Fun and Games: show
Levels that I may make by 20XX
- Remake of Airship Armada
- Level using the Turbo FLUDD
- Level using the Flying Cap
- A level on the moon

- Syzygy Labs
- Maybe some sort of Metroidvania level
- Sneaking level
- A mystery


Random Stuff
Image
Image
Czasoprzestrzen/Spacetime... If only somebody knew this hidden gem...

Huh?
GENERATION 31: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Konradix
The Legacy

 
Posts: 689
Joined: May 12th, 2010, 8:14 am
Location: Studying the Grand History in the Ruins of the World

Runolympics 2015 Participation

Thumbs Up given: 85 times
Thumbs Up received: 39 times

Re: A platform game

Postby Suyo » May 13th, 2010, 12:46 am

Drag 'n' Drop or Code?

Konradix wrote:(when I'm walking to left then it uses left sprite walking, but when im walking to right its not flipping horizontal, its changing left walking to right.)


Sounds like you have a problem there. Can you post your code?
Image

Image

Image

Image

Image

Image
User avatar
Suyo
"quite easily the most manly man of all" --Raz

Error contacting Twitter
Error contacting last.fm
 
Posts: 2771
Joined: July 28th, 2009, 2:41 am
Location: Nuremberg (Germany)

Runouw Votes Winner
For winning the RV New Year 2012 Award for Best Moderator. Like you didn't know. XD

Thumbs Up given: 26 times
Thumbs Up received: 359 times

Re: A platform game

Postby Konradix » May 13th, 2010, 12:32 pm

Well I had one which actually flipped horizontal when it went to the left. There is it:

CODE IN PLAYER
Code: Select all
onClipEvent (load) {
   gravity = 10;
   scale = _xscale;
   walkSpeed = 6;
   maxjump = 6;
}
onClipEvent (enterFrame) {
   if (air == true) {
      _y += gravity;
      state = 3;
   }
   if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
      _x -= walkSpeed;
      _xscale = -scale;
   }
   if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
      _x += walkSpeed;
      _xscale = scale;
   }
   if (_root.platforms.hitTest(_x, _y, true)) {
      air = false;
   } else {
      air = true;
   }
   if (Key.isDown(Key.SPACE) && jump == true) {
      _y -= jumpSpeed;
   }
   if (air == false) {
      jump = true;
      jumpcount = 0;
      jumpSpeed = 22;
   }
   if (Key.isDown(Key.SPACE)) {
      jumpcount += 1;
   }
   if (jumpcount > maxjump && jumpSpeed > -2) {
      jumpSpeed -= 2;
   }
   if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe < 4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe < 4) {
      state = 1;
   }
   if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe < 4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe < 4) {
      state = 2;
   }
   if (!Key.isDown(65)) {
      gotoAndStop(state);
   }
   _root.statetxt = state;
}
onClipEvent (keyUp) {
   if (Key.getCode() == 83) {
      jump = false;
   }
}
"Men cry not for themselves, but for their comrades"

Check out my newest level called:
Image
Be sure to leave a comment and a rating ;)
Fun and Games: show
Levels that I may make by 20XX
- Remake of Airship Armada
- Level using the Turbo FLUDD
- Level using the Flying Cap
- A level on the moon

- Syzygy Labs
- Maybe some sort of Metroidvania level
- Sneaking level
- A mystery


Random Stuff
Image
Image
Czasoprzestrzen/Spacetime... If only somebody knew this hidden gem...

Huh?
GENERATION 31: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Konradix
The Legacy

 
Posts: 689
Joined: May 12th, 2010, 8:14 am
Location: Studying the Grand History in the Ruins of the World

Runolympics 2015 Participation

Thumbs Up given: 85 times
Thumbs Up received: 39 times

Re: A platform game

Postby Buff_ » May 13th, 2010, 12:36 pm

That looks awfully like coding for flash, are you using flash?
User avatar
Buff_
A rather stellar gentleman

Error contacting Twitter
 
Posts: 2827
Joined: August 7th, 2009, 6:48 am
Location: Under the sink

The Start of Something Big

Thumbs Up given: 10 times
Thumbs Up received: 104 times

Re: A platform game

Postby Konradix » May 13th, 2010, 1:02 pm

Yes im using flash. It was called Platform Source maybe.
"Men cry not for themselves, but for their comrades"

Check out my newest level called:
Image
Be sure to leave a comment and a rating ;)
Fun and Games: show
Levels that I may make by 20XX
- Remake of Airship Armada
- Level using the Turbo FLUDD
- Level using the Flying Cap
- A level on the moon

- Syzygy Labs
- Maybe some sort of Metroidvania level
- Sneaking level
- A mystery


Random Stuff
Image
Image
Czasoprzestrzen/Spacetime... If only somebody knew this hidden gem...

Huh?
GENERATION 31: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Konradix
The Legacy

 
Posts: 689
Joined: May 12th, 2010, 8:14 am
Location: Studying the Grand History in the Ruins of the World

Runolympics 2015 Participation

Thumbs Up given: 85 times
Thumbs Up received: 39 times

Re: A platform game

Postby Buff_ » May 13th, 2010, 1:21 pm

I'll look at the code, and test something out; see if I can do something with it. Also, can I see what you're actually doing? I need to see what the sprites are, I'm only using a square..

EDIT: Should this be moved to Flash Player Showcase?
User avatar
Buff_
A rather stellar gentleman

Error contacting Twitter
 
Posts: 2827
Joined: August 7th, 2009, 6:48 am
Location: Under the sink

The Start of Something Big

Thumbs Up given: 10 times
Thumbs Up received: 104 times

Re: A platform game

Postby Buff_ » May 27th, 2010, 9:50 am

DOUBLE POST!!!!!!! New info on this..

I use this.
Code: Select all
onClipEvent (load) {
   var grav:Number = 0;
   var run:Number = 10;
   var wlk:Number = 2.5;
   var speed:Number = run;
   var jumpHeight:Number = 12;
   var tjump:Boolean = false;
   var slow:Number = .7;
   var slowspd:Number = speed/2;
   var setspeed:Number = speed;
   var scale:Number = _xscale;
   var ex:Number = 5;
   this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
   grav++;
   _y += grav;
   if (Key.isDown(65)) {
      setspeed = wlk;
   } else {
      setspeed = run;
   }
   while (_root.ground.hitTest(_x, _y, true)) {

      tjump = false;
      _y--;
      grav = 5;
   }
   if (_root.water.hitTest(_x, _y, true)) {
      grav *= slow*1.25;
      speed = slowspd;
   } else {
      speed = setspeed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
      _xscale = scale;
      if (_root.ground.hitTest(_x, _y+3, true)) {
         this.gotoAndStop(1);
      } else {
         if (djump == false) {
            this.gotoAndStop(2);
         } else if (tjump == false) {
            this.gotoAndStop(4);
         } else {
            this.gotoAndStop(5);
         }
      }
   } else if (Key.isDown(Key.LEFT)) {
      _x -= speed;
      _xscale = -scale;
      if (_root.ground.hitTest(_x, _y+3, true)) {
         this.gotoAndStop(1);
      } else {
         if (djump == false) {
            this.gotoAndStop(2);
         } else if (tjump == false) {
            this.gotoAndStop(4);
         } else {
            this.gotoAndStop(5);
         }
      }
   } else {
      if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(68) && !Key.isDown(83)) {
         this.gotoAndStop(3);
      }
   }
   if (Key.isDown(68) && !Key.isDown(Key.UP) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(83) && _root.ground.hitTest(_x, _y+3, true)) {
      this.gotoAndStop(8);
   }
   if (Key.isDown(83) && !Key.isDown(Key.RIGHT) && !Key.isDown(Key.LEFT) && !Key.isDown(Key.UP) && !Key.isDown(68) && _root.ground.hitTest(_x, _y+3, true) && _currentframe != 6) {
      this.gotoAndStop(7);
   } else if (Key.isDown(83) && grav>1) {
      this.gotoAndStop(6);
   }
   if (Key.isDown(Key.UP) && _root.ground.hitTest(_x, _y+3, true)) {
      grav = -jumpHeight;
      _y -= 4;
      this.gotoAndStop(2);
   } else if (Key.isDown(Key.UP) && djump == false && grav>0 && tjump == false) {
      grav = -dbl;

      this.gotoAndStop(4);
   } else if (Key.isDown(68) && tjump == false && grav>1) {
      grav = -tri;
      tjump = true;
      this.gotoAndStop(5);
   }
   if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
      _x -= speed;
   }
   if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
      _x += speed;
   }
   if (_root.ground.hitTest(_x, _y-_height-15, true)) {
      grav = 1;
   }
}


This automatically changes the characters direction. You may need to edit some of the hitTests though.
User avatar
Buff_
A rather stellar gentleman

Error contacting Twitter
 
Posts: 2827
Joined: August 7th, 2009, 6:48 am
Location: Under the sink

The Start of Something Big

Thumbs Up given: 10 times
Thumbs Up received: 104 times

Re: A platform game

Postby Konradix » May 28th, 2010, 9:32 am

So I just have to make idle guy, jumping guy and walking? Or how, cuz im not sure how you've done that.
"Men cry not for themselves, but for their comrades"

Check out my newest level called:
Image
Be sure to leave a comment and a rating ;)
Fun and Games: show
Levels that I may make by 20XX
- Remake of Airship Armada
- Level using the Turbo FLUDD
- Level using the Flying Cap
- A level on the moon

- Syzygy Labs
- Maybe some sort of Metroidvania level
- Sneaking level
- A mystery


Random Stuff
Image
Image
Czasoprzestrzen/Spacetime... If only somebody knew this hidden gem...

Huh?
GENERATION 31: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Konradix
The Legacy

 
Posts: 689
Joined: May 12th, 2010, 8:14 am
Location: Studying the Grand History in the Ruins of the World

Runolympics 2015 Participation

Thumbs Up given: 85 times
Thumbs Up received: 39 times

Re: A platform game

Postby Buff_ » May 28th, 2010, 9:56 am

Walk=Frame 1
Jump=Frame 2
Idle=Frame 3
Moving and in the air=Frame 4

This is all inside the symbol.
User avatar
Buff_
A rather stellar gentleman

Error contacting Twitter
 
Posts: 2827
Joined: August 7th, 2009, 6:48 am
Location: Under the sink

The Start of Something Big

Thumbs Up given: 10 times
Thumbs Up received: 104 times

Re: A platform game

Postby Konradix » June 3rd, 2010, 5:27 am

Ok guy is turning but what should I put in a platform?
"Men cry not for themselves, but for their comrades"

Check out my newest level called:
Image
Be sure to leave a comment and a rating ;)
Fun and Games: show
Levels that I may make by 20XX
- Remake of Airship Armada
- Level using the Turbo FLUDD
- Level using the Flying Cap
- A level on the moon

- Syzygy Labs
- Maybe some sort of Metroidvania level
- Sneaking level
- A mystery


Random Stuff
Image
Image
Czasoprzestrzen/Spacetime... If only somebody knew this hidden gem...

Huh?
GENERATION 31: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.
User avatar
Konradix
The Legacy

 
Posts: 689
Joined: May 12th, 2010, 8:14 am
Location: Studying the Grand History in the Ruins of the World

Runolympics 2015 Participation

Thumbs Up given: 85 times
Thumbs Up received: 39 times

Next

Return to Programming