• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ghigared

I need help

5 posts in this topic

How do you develop 2d jumping like the kind found in megaman, or Mario. I know you have to control y velocity I have gotten that far I even have my character jumping but he never caps his jump if I leave the jumping button pressed he will jump forever any help would be greatly appreciated and thank you in advance ps I'm using slick2d with Java
0

Share this post


Link to post
Share on other sites

You can either use a timer (i.e. "from now until the next second, give the player an upward y velocity; after this second is over, let gravity take effect."), or you could have a counter (which kinda acts like a timer; i.e. "if counter <= 0, let gravity take effect; if counter > 0, give upward y velocity; when jump button is pressed, set counter to 100 (or whatever) and decrement it every update loop"), or if you're doing a more "physically based" jump you can add some amount to the y velocity to make it positive and then let gravity slowly pull it back down.

 

However, in all of these methods, you're going to probably want to first check if the player is touching the ground when they press jump. If the player is not touching the ground, ignore the press. If the player is touching the ground, go ahead and jump.

Edited by Cornstalks
1

Share this post


Link to post
Share on other sites

How do you develop 2d jumping like the kind found in megaman, or Mario. I know you have to control y velocity I have gotten that far I even have my character jumping but he never caps his jump if I leave the jumping button pressed he will jump forever any help would be greatly appreciated and thank you in advance ps I'm using slick2d with Java

Have you modelled gravity into your game yet? If not, I would do that first. Place the character up in the air somewhere and apply gravitational forces to pull your character down. (By the way, you can apply this downward force all the time--which is physically realistic anyway.) You'll also need to implement basic collision detection and response between the character and a platform.

So with these components you have:
- character is up in the air
- gravity pulls it down
- platforms "catch" the character so it doesn't fall forever

With these in place, implementing jumping is simply a matter of giving the character an initial upward velocity when the key is pressed. The opposition of gravity will gradually decelerate the character, it will stop moving at the peak of the jump, and beginning falling. If implemented correctly, you should get a nice, smooth, parabolic jump. That's it in a nutshell, but there are some cases you need to account for. As Cornstalks said, you need to make sure you're already on the ground before you can jump. Also, you need all around collision response to handle, for example, what happens when the character jumps and hit its head on a platform above.

Hopefully that helps. Edited by thok
2

Share this post


Link to post
Share on other sites

Let's say you would like to jump up for 3 tiles each of height 16, check this

 

int x_pos, y_pos; // Current position
boolean jump = false;

int jump_y = 0; // The position to jump

public void doFrame(){
    if (onGround()){ // Implement this method
        if (isPressed(VK_SPACE) && !jump){
            jump = true;
            jump_y = y_pos - 16*3; // 3 tiles of height 16 px
        }
    }
    if (jump){
        y_pos -= y_vel;    // Move the character up
        if (y_pos <= jump_y){
            jump = false;
        }
    } else {
        // Apply gravity
        y_pos += y_vel;
    }

}

 

 

Hope this code helps.

Edited by SHC
0

Share this post


Link to post
Share on other sites

(By the way, you can apply this downward force all the time--which is physically realistic anyway.

 

So when this force is applied all the time, when there is collision it doesn't change correct?

 

this :

player.setLocation(x, y=(float)(y +(9.8*gravity)));

 

seems to be working to pull an item forcefully down. I'm guessing that when there is collision the y location will be set to the position of the floor - the height of the player, and the gravity will be set to 0? Thank you very much for the help.

0

Share this post


Link to post
Share on other sites

I figured it all out guys, thank you all for your help :) I'll keep this post alive, and show you guys my progress just incase any one is interested :)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0