• 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
NicholasLopez

Help with jumping

44 posts in this topic

[quote name='szecs' timestamp='1318584062' post='4872457']
then you'll have to [b]pay[/b] for it. Either in nature or with hard cash.
[/quote]
So, like with pinecones, rocks and shit? ;)

[quote]
EDIT: maybe you are just on the wrong track. Wrong track = learning from others' code as a beginner. I'm sure someone can link to articles that carefully explain why this is not good (for a beginner). Learn by doing on your own. (Well, I'm against learning from tutarials too, but that's a different matter).
[/quote]

I am somewhat against tutorials that just show how instead of why. However, I think in writing [url="http://http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx"]my own tutorial[/url] I hit on the right balance. I try to take the user through the actual process, so that at points the tutorial actually goes back an reworks previous code so the user actually understands *why* you do something. Plus, its half tutorial and half instruction. Granted, someone could jump to the last chapter, grab the sample code and run from there but that's their choice.

We all learn differently and we all need to learn from something. My beef is tutorials that simply say do this then that then this, which sadly is the majority. A person isn't really learning anything from this, other than brushing up their typing skills. Now the downside is, in order to explain the why with the how, the tutorial writer needs to spend a lot more effort and the tutorials tend to be much longer.
0

Share this post


Link to post
Share on other sites
Like ive said, I knew this was going to happen, I knew you werent just going to help me with code. You are are riddles and stuff.[u] I learn by studying, you may learn differently, I don't[/u]. I don't have the personal time to invest in learning something complex, im sure you were the same (you learned in a classroom). You are all beyond that point that you are 1337.

Now asI said in my very first post on this thread, I would have liked down right help, but nope.avi, you just proxied away at the conversation. If you want to help me how I like to be helped (and stop assuming things differently, I dont want a game, I want a player), thats fine.

Thanks
-6

Share this post


Link to post
Share on other sites
Ok, printf debugging help ahead.

Dump the offsets right before the apply_surface call, like
[code]
printf("x_offSet=%d,y_offSet=%d\n", x_offSet, y_offSet);
[/code]

Then put another one within apply_surface dumping the parameters, like:
[code]
printf("x=%d, y=%d\n", x, y);
[/code]

Run your app and study the console output.
1

Share this post


Link to post
Share on other sites
[quote name='DrNicholas' timestamp='1318607487' post='4872551']
Like ive said, I knew this was going to happen, I knew you werent just going to help me with code. You are are riddles and stuff.[u] I learn by studying, you may learn differently, I don't[/u]. I don't have the personal time to invest in learning something complex, im sure you were the same (you learned in a classroom). You are all beyond that point that you are 1337.

Now asI said in my very first post on this thread, I would have liked down right help, but nope.avi, you just proxied away at the conversation. If you want to help me how I like to be helped (and stop assuming things differently, I dont want a game, I want a player), thats fine.

Thanks
[/quote]

Whelp, good luck having someone make you a player who jumps, because, if you can't do that, then you won't be able to program a game either.

If you don't know what wrong with:
[code]
apply_surface( x_offSet && y_offSet, SCREEN_HEIGHT - PLAYER_HEIGHT && SCREEN_WIDTH - PLAYER_WIDTH, player, screen, &clipsRight[ frame ] );
[/code]
when the prototype for apply_surface is:
[code]void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL );
[/code]

Then, go back to the basics.
2

Share this post


Link to post
Share on other sites
Justin, your code still isn't quite right. What happens when u hold down space?

Also, if holding left or right, you're going to apply double the gravity (ay) twice in one frame.

Jump velocity should be negative when 1st hitting space (moving up screen).

And, finally, as you hold down LEFT )or RIGHT) you're going to constantly increase the velocity. So, just set vx= (whatever), not vx += or vx -= when checking keys.

As I said in my 1st post, just check for space on key up, and only apply gravity when moving. Just set the velocity when checking key presses, don't apply it to x or y then.
[quote name='JustinDaniel' timestamp='1318650655' post='4872744']
Well, i should not be doing this, but uh, it makes me mad how people learn to program games when they dont even know basics of c++ or whatever language it might be, copying and pasting code doesnt get you anywhere, if you have to become a game programmer then you gotta work for it. Asking for help is not bad but asking others to write code for you is totally annoying especially in programming.
[code]
#include <sdl.h>
#include <iostream>
#include <sdl_image.h>
#include <string>
#include <cstdlib>
#include <ctime>

int main( int argc, char* argv[] )
{
std::srand( std::time(0) );

if( SDL_Init( SDL_INIT_VIDEO ) == -1 )
{
std::cout << "Failed to initialize" << SDL_GetError() << "\n";
return false;
}
std::atexit(&SDL_Quit);

SDL_Surface *screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
if( screen == NULL )
{
std::cout << " Failed to set video " << SDL_GetError() << "\n";
return false;
}

SDL_Surface *square = IMG_Load( "square.bmp" );
if( square == NULL )
{
std::cout << "Failed to open square" << SDL_GetError() << "\n";
return false;
}

int x = 20;
int y = 460;
int vx = 0;
int vy = 20;
int ay = 2;
bool jumping = false;
bool quit = false;
while( !quit )
{
SDL_Event event;
while( SDL_PollEvent( &event ) )
{
if( event.type == SDL_KEYDOWN )
{
switch( event.key.keysym.sym )
{
case SDLK_RIGHT: vx += square->w /3; break;
case SDLK_LEFT: vx -= square->w/3; break;
case SDLK_SPACE:
vy = 20;
jumping = true;
}

}
else if( event.type == SDL_KEYUP )
{
switch( event.key.keysym.sym )
{
case SDLK_RIGHT: vx -= square->w /3; break;
case SDLK_LEFT: vx += square->w /3; break;
if( jumping )
{
if( vy >= -20 )
{
vy = vy - ay;
y = y + vy;
}
}
if( y + square->h > screen->h )
{
y = 460;
}
}
}
if( event.type == SDL_QUIT)
{
quit = true;
}
}
SDL_Rect rect = {x, y, square->w, square->h };

x += vx;

if( jumping )
{
y -= vy;
}
if( vy >= -20 )
{
vy = vy - ay;
}
if( y + square->h > screen->h )
{
y = 460;
}
SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF,0xFF,0xFF ) );
SDL_BlitSurface( square, 0, screen, &rect );

SDL_Flip(screen);
}
SDL_FreeSurface( square );
return 0;
}
[/code]

I have given you the entire code on how to make a square jump, Learn from it and see what you can do it with your game, Atleast go through some of the code and learn what it does, learn from it, DONT copy paste.
Peace.
[/quote]
0

Share this post


Link to post
Share on other sites
[quote name='BeerNutts' timestamp='1318722151' post='4872992']
As I said in my 1st post, just check for space on key up, and only apply gravity when moving.
[/quote]
While that's a totally valid solution, usually you want to implement character actions on key down events. The reason is because that's how 99% of games do it (so they'll expect it), and especially because there is a small delay between when a key is pressed down and when it is released up. Most gamers will be upset by the delay, expecting the game to respond as soon as they hit the key down.

It can work just fine in some games, but it's something to consider. Most games only allow jumping when the character is touching the ground. That way the character can't double jump, plus it can be implemented as a key down event without worry of double-processing the event.
0

Share this post


Link to post
Share on other sites
this thread was quite funny to read, its the common case of someone doing a few online tutorial believing they instantly know how to program and that they know best ignoring other peoples advice
1

Share this post


Link to post
Share on other sites
[quote name='Cornstalks' timestamp='1318723352' post='4872995']
[quote name='BeerNutts' timestamp='1318722151' post='4872992']
As I said in my 1st post, just check for space on key up, and only apply gravity when moving.
[/quote]
While that's a totally valid solution, usually you want to implement character actions on key down events. The reason is because that's how 99% of games do it (so they'll expect it), and especially because there is a small delay between when a key is pressed down and when it is released up. Most gamers will be upset by the delay, expecting the game to respond as soon as they hit the key down.

It can work just fine in some games, but it's something to consider. Most games only allow jumping when the character is touching the ground. That way the character can't double jump, plus it can be implemented as a key down event without worry of double-processing the event.
[/quote]

Well, you can do it, but the way Justin did it isn't valid. He didn't check if (!Jumping) first, which would be the way to do it. After thinking about it, it's better to do it on down press, and check if (!Jumping).

Good point.
0

Share this post


Link to post
Share on other sites
He's just a troll. I doubt he ever had any intention of putting forth any effort, and rather just wanted to come piss a few people off for the lolz. Let's please just let this thread die. RIP thread.
0

Share this post


Link to post
Share on other sites
I wanted to put forth effort, i wanted some code to start off with, not some people just gettin angry (ON STEROIDS) with me about coding... You only gave me vague riddles, you say you gave code, but it didnt work and didnt say where it goes. id still like the help put in there, but its like non e of you could bring yourselves to do such a simple task. so i just play with my raycasting engine instead.

but i voew anytime i see someone getting picked on, i shall post a picture of the riddler, and if i can help them (when i come online), i will to the best of my ability.
-4

Share this post


Link to post
Share on other sites
[quote]I wanted to put forth effort,[/quote]

So far as the evidence in this thread goes you've not even tried to debug the code yourself leave alone try to understand it. What exactly is meant by "effort"?

And by the way, if I were you I would show some gratitude to the people who've actually bothered to take your code and worked with it to try and get the jumping code working whether the code works or not. They've spent their valuable time and effort for no material benefit. If you cannot do so, at least avoid insulting or belittling them.

Your approach is wrong. Please understand that respect works wonders. Respecting the people who're trying to help will get you far.
0

Share this post


Link to post
Share on other sites
I see what you did there, took a fragment of a sentence. Not to troll or flame, but quote the whole sentence.

[quote]I wanted to put forth effort, i wanted some code to start off with, not some people just gettin angry (ON STEROIDS) with me about coding.[/quote]

you just did not want to help me with a simple task, and none of you can truly answer why you did not want to put code in. you all highly disappointed me, you really dont want to teach people or help them, looking at everything your only true answer is "look in the book". Seeing as though this is the free section I suspected as much but none of you truly are charitable or wanting to help people. I already thanked them for trying to help, but i also told them their help didnt help. im surprised you all get mad easily over this. i really dont want your help anymore, i couldnt do the thing for class.
-2

Share this post


Link to post
Share on other sites
From where I sit, you can't even put in the effort to make a coherent forum post. You haven't even put in the effort to download a [url="http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express"]working debugger[/url]. 2 people post code showing how to implement jumping and you get bitchy that they didn't [b]do your work for you.[/b]

People, programmers in particular, hate stupid, lazy, entitled, inconsiderate, ungrateful, passive-aggressive, guilt tripping, immature children. The less you look like one, the better help you'll receive. Welcome to the internet. Hopefully you'll learn [i]something[/i] if you're not a troll.
2

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0