These forums are closed for viewing purposes only. To join the McLeodGaming community, please register at the new forums here.

McLeodGaming.com Forum Index
 FAQ  •  Search  •  Memberlist  •  Usergroups   •  Register  •  Profile  •  Log in to check your private messages  •  Log in
 FAU - (Flash Artist University) View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.This topic is locked: you cannot edit posts or make replies.
Author Message
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Sun Aug 19, 2007 8:00 pm Reply with quoteBack to top

Ok. I think I would need to make it where when the player hittest the platform the gravity = 0 and then the players _y turns back to normal and the jump = false and onfloor = true. But i dont know how to make the _y turn back to normal. But thats only if the above idea is correct.
View user's profileSend private message 
Racoon
Level 19


Joined: 14 Dec 2006
Posts: 3279

Gold 11068
Pixel(s)
Demerits 0

PostPosted: Sun Aug 19, 2007 8:09 pm Reply with quoteBack to top

Ehehe, I love my students....student.
You are on a good path, but I got to know...
When you jump...what happens to your gravity?
And also...what happens when gravity is ++?
View user's profileSend private message 
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Sun Aug 19, 2007 8:25 pm Reply with quoteBack to top

Well when the player jumps , with the code i have now, the gravity = -12 so when i land i set it back to 0. And the gravity++ makes it continue to go up by 1. Oh so maybe i dont need to set the gravity = 0 becuz the gravity ++ will do that for me. Am i correct?
View user's profileSend private message 
Racoon
Level 19


Joined: 14 Dec 2006
Posts: 3279

Gold 11068
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 8:56 am Reply with quoteBack to top

hmm, interesting...
So your gravity will always increase by one correct?
So if your gravity always increases by one how could the platform stop it from
going past zero?
How could it be canceled out by a platform?
View user's profileSend private message 
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 9:40 pm Reply with quoteBack to top

I think i could make the platform so that when it is hitTest by the player gravity = 0. Confused
View user's profileSend private message 
Racoon
Level 19


Joined: 14 Dec 2006
Posts: 3279

Gold 11068
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 9:54 pm Reply with quoteBack to top

Well what would happen if we put a code where
++ meets -- ?
View user's profileSend private message 
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 9:56 pm Reply with quoteBack to top

Oh that would make them cancel out. I forgot about the (--) sugn, Well didnt really even know about it. LOL. I understand what you sayin tho.
View user's profileSend private message 
Racoon
Level 19


Joined: 14 Dec 2006
Posts: 3279

Gold 11068
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 10:40 pm Reply with quoteBack to top

x2i wrote:
Code:

onClipEvent (load) {
   //Sets the initial speed and downwards pull
   gravity = 5;
   speed = 5;
   isJump = true;
}
onClipEvent (enterFrame) {
   //Moves the player up or down
   gravity++;
   _y += gravity;
   //Keys to move left and right
   if (Key.isDown(Key.LEFT)) {
      _x -= speed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
   }
   //Check whether the character is already jumping
   //If not then jump
   if (Key.isDown(Key.UP) && isJump == false) {
      isJump = true;
      _y -= 5;
      gravity = -13;
   }
}


//////platforms code/////



onEnterFrame = function () {
   // Check whether platform has been landed on
   while (hitTest(_root.player._x, _root.player._y, true)) {
      // Stop player and allow him to jump again
      _root.player.isJump = false;
      _root.player.gravity = 0;
      _root.player._y--;
   }
};


In truth we are basically modeling our code after x2i's

Now with the instruction thus far you should really see how this particular code works.
However my method takes this formula and changes it a bit.
First break done this code, we'll get into making a simple game in a moment.
View user's profileSend private message 
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 10:45 pm Reply with quoteBack to top

I understand the code fully but i dont understand what u were asking me to do in your last post. Srry i was sleepin in class.
View user's profileSend private message 
Racoon
Level 19


Joined: 14 Dec 2006
Posts: 3279

Gold 11068
Pixel(s)
Demerits 0

PostPosted: Wed Aug 22, 2007 10:53 pm Reply with quoteBack to top

explain it in detail.
It'll help with whats next.
View user's profileSend private message 
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Thu Aug 23, 2007 12:00 am Reply with quoteBack to top

Ok. Here I go:
Code:
onClipEvent (load) {
   //Sets the initial speed and downwards pull
   gravity = 5;
   speed = 5;
   isJump = true;
}

^ These are the variables that control the MC's speed, gravity, and also checks if it can jump or not.

Code:
onClipEvent (enterFrame) {
   //Moves the player up or down
   gravity++;
   _y += gravity;
   //Keys to move left and right
   if (Key.isDown(Key.LEFT)) {
      _x -= speed;
   }
   if (Key.isDown(Key.RIGHT)) {
      _x += speed;
   }

^ This code enables the MC to be able to move left and right when the arrow keys ( Left and Right ) are down. Also the gravity++ makes the gravity increase by 1.

Code:
if (Key.isDown(Key.UP) && isJump == false) {
      isJump = true;
      _y -= 5;
      gravity = -13;
   }
}

^ This code makes the MC jump when the arrow Key. Up is down only if the MC is not already jumping. To make the jump effect the gravity is lowered so the MC will float up off of the platform.

Code:
//////platforms code/////



onEnterFrame = function () {
   // Check whether platform has been landed on
   while (hitTest(_root.player._x, _root.player._y, true)) {
      // Stop player and allow him to jump again
      _root.player.isJump = false;
      _root.player.gravity = 0;
      _root.player._y--;
   }
};

^This code goes on the platform. This code makes the MC stop moving when he lands on the platform. It also makes it where the MC can jump again.

Theres my explanation teach. What do u think?
View user's profileSend private message 
chif ii
Level 16


Joined: 16 Feb 2007
Posts: 2320
Location: maybe later
Gold 5163
Pixel(s)
Demerits 0

PostPosted: Sun Aug 26, 2007 5:48 pm Reply with quoteBack to top

I take it you guys aren't on particle behavior yet, huh?
View user's profileSend private message[ Hidden ]Visit poster's website
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Sun Aug 26, 2007 8:51 pm Reply with quoteBack to top

chif ii wrote:
I take it you guys aren't on particle behavior yet, huh?


What is that? And no i dont think so.
View user's profileSend private message 
chif ii
Level 16


Joined: 16 Feb 2007
Posts: 2320
Location: maybe later
Gold 5163
Pixel(s)
Demerits 0

PostPosted: Sun Aug 26, 2007 10:31 pm Reply with quoteBack to top

That's the movement of free-moving items, with and without the influence of outside forces, that are independent of one another but interact like a whole. Here, take this as an example.
View user's profileSend private message[ Hidden ]Visit poster's website
amari77
Level 4


Joined: 19 Jun 2007
Posts: 140
Location: At the comp
Gold 400
Pixel(s)
Demerits 0

PostPosted: Mon Aug 27, 2007 1:22 am Reply with quoteBack to top

nope havent learned that yet but its nice. Very Happy
View user's profileSend private message 
Display posts from previous:      
This forum is locked: you cannot post, reply to, or edit topics.This topic is locked: you cannot edit posts or make replies.


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme :: All times are GMT - 4 Hours