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

Wanting to build a 2d RPG but kind of lost

15 posts in this topic

Okay, so I have a pretty basic understanding of C++.  This is roughly the information I've covered so far:

 

 

Storing Data and getting user input

Performing calculations and displaying output

If Else Statements

Loops

Functions

Arrays

And references.

 

This is all great and I enjoy programming but I REALLY want to start working with graphics and move towards 2d games.  I've started to look into libraries like SDL and some of it looks really weird and then other parts I can understand.  Usually after I get past the initial "setting up the SDL screen" tutorial it gets way advanced and I lose it.  I really want to start moving into something with graphics because it's starting to feel like the console just isn't doing it for me anymore.  With what I've learned, I have been able to program a decent text based RPG. 

 

The only things I haven't gotten to/don't completely understand when I try to do are pointers and classes. 

 

So I guess what i'm asking is... How do I progress towards making a 2d game of some sort?  Where can I start or am I going about it wrong?  I've tried looking at source code from other people's games or basic SDL game tutorials but it just seems very overwhelming.  Can anyone help me out?

 

Thanks!

0

Share this post


Link to post
Share on other sites

I could write what I'm doing. First find out how to paint any picture on screen. Then how to move it. Later make of it class to better handling. Don't really how to do it in SDL. I started from darkGDK which is in c++ and easy to learn. I suggest you to try it ;) http://youtu.be/prQ2RfnrP_8 if you will try, and later same guy have more tuts 

0

Share this post


Link to post
Share on other sites

You sound a lot like me.

 

Just gotta give it time and learn all of the basics.  

0

Share this post


Link to post
Share on other sites


Usually after I get past the initial "setting up the SDL screen" tutorial it gets way advanced and I lose it.

 

Hi. Are you following Lazy Foo's tutorials? If you aren't, give that a try. His are pretty "famous" for being a good starting point. If you are following them already, you should try doing as the tutorial tells you, and follow each tutorial in the correct order. That way, the topics will get increasingly advanced, not suddenly too advanced.

 


The only things I haven't gotten to/don't completely understand when I try to do are pointers and classes.

 

You should make sure you understand how to use pointers first, because the SDL library does require you to use pointers for many of its function calls.

2

Share this post


Link to post
Share on other sites

Okay, so I have a pretty basic understanding of C++.  This is roughly the information I've covered so far:

 

 

Storing Data and getting user input

Performing calculations and displaying output

If Else Statements

Loops

Functions

Arrays

And references.

 

This is all great and I enjoy programming but I REALLY want to start working with graphics and move towards 2d games.  I've started to look into libraries like SDL and some of it looks really weird and then other parts I can understand.  Usually after I get past the initial "setting up the SDL screen" tutorial it gets way advanced and I lose it.  I really want to start moving into something with graphics because it's starting to feel like the console just isn't doing it for me anymore.  With what I've learned, I have been able to program a decent text based RPG. 

 

The only things I haven't gotten to/don't completely understand when I try to do are pointers and classes. 

 

So I guess what i'm asking is... How do I progress towards making a 2d game of some sort?  Where can I start or am I going about it wrong?  I've tried looking at source code from other people's games or basic SDL game tutorials but it just seems very overwhelming.  Can anyone help me out?

 

Thanks!

You do understand that "RPG" is the hardest most difficult genre to make cause RPG = most genres in one.

IMO you don't need to know pointers and classes to make a rpg, but you will need functions.

 

You should make some set of goals to achieve:
1: I want to learn how to open a window with SDL library.

2: Draw simple shapes

2: Move shapes around the screen.

3: Load texture and apply to shape

4: Animate the sprite.

5: Time step

(You have a good plan to setup the most basic of game)

^^ good luck.

0

Share this post


Link to post
Share on other sites

RPG is not the "most difficult genre", it's probably the most scalable one in term of difficulty since you can do a quite basic RPG.

 

To be honest "pointers and classes" ARE the answer you are looking for, you NEED to know about them to go further. It's quite simple actually. Classes are like a template of every variables who will contain the data representing an entity(object) and such. Instances are the objects themselves instantiated from the class, you can have multiple instance of the same class in memory at the same time. Pointers are just identifiers in form of number telling you where is the instance of each objects you have is so you can access them to use them.

 

At your point, I would say you should learn to draw shapes and store them to be able to move them independently. Once you manage to do that you are much more advanced.

 

Other than that, learning how to use an API (like SDL) is important, knowing the language is one thing, but it means nothing without APIs to do things with. Reading the documentation and official guides are always a great help.

2

Share this post


Link to post
Share on other sites

Learn basics.  Start small.  Make games like pong, galaga, asteroids, tetris.  Once you can do those... you'll be ready to move on to bigger things.

Patience.

1

Share this post


Link to post
Share on other sites

The screen is an array of pixels (usually each pixel is an unsigned 32-bit value, with bits 0-7 being red, 8-15 green, 16-23 blue, and 24-31 unused). All you really need SDL for is to provide you with a pointer to such an array that will show up on the actual screen. Then try drawing simple shapes like rectangles:

void DrawRect(unsigned long *screen, int screenWidth, int x, int y, int w, int h, unsigned long color)
{
    for(int j = 0; j < h; j++)
        for(int i = 0; i < w; i++)
            screen[(y + j) * screenWidth + (x + i)] = color;
}

 
The SDL image loading and blitting functions aren't really necessary, although they might save you some time compared to learning how to load .bmp files yourself, and write your own blitting functions.

After that, you'll need to figure out how to take keyboard input with SDL. Then you can change the position where you draw the rectangle when the arrow keys are pressed, and you have the beginnings of a game smile.png

As Dunge says, understanding pointers and classes will be the next big leap in your programming abilities. I had trouble with pointers at first too, but they're pretty straightforward once you understand understand what memory is. Again, it's more or less one massive array of bytes. Say you have 1GB of RAM in your computer, then memory is like a 1 billion byte array. A memory address is just a number... an index into that array.
 
All variables are stored somewhere in memory. Different variable types (char, int, float, double) are different sizes, but all pointers are the same size (4 bytes) because they all just store the address of another variable. The pointer type tells the compiler how to interpret the data at that address.
 
Classes are the natural evolution of structs in C. But first let's see where structs came from smile.png Say you have 4 player characters in your RPG, and each of them has a hit point variable, and max hit points, and attack power. You could do like this:
 

int hp[4];
int hpMax[4];
int attack[4];

 
But that can get very messy because those arrays pretty much have to be global variables, so you can pass a player number to a function and the function will be able to access the player's hit points and such, like this
 

void AdjustPlayerHP(int player, int change)
{
    hp[player] += change;
    if (hp[player] >= hpMax[player])
        hp[player] = hpMax[player];
    else if (hp[player] <= 0)
        SetPlayerDead(player);
}

 
Much better to do this
 

struct Player
{
    int hp;
    int hpMax;
    int attack;
};

Player player[4];

void AdjustPlayerHP(Player *player, int change)
{
    player->hp += change;
    if (player->hp >= player->hpMax)
        player->hp = player->hpMax;
    else if (player->hp <= 0)
        SetPlayerDead(player);
}

 
That way, the player functions don't need to know about any global variables, and can operate on any Player struct, rather than only the ones in a specific global array.
This is what is known as "object oriented programming". Classes are an even more convenient way of implementing this pattern:
 

class Player
{
public:
    void adjustHP(int change);
    void setDead();

    int hp;
    int hpMax;
    int attack;
};

Player player[4];

void Player::adjustHP(int change)
{
    hp += change;
    if (hp >= hpMax)
        hp = hpMax;
    else if (hp <= 0)
        setDead();
}

 
Class member functions have an implicit first argument which is the same as the Player *player argument in the struct version of this code. So instead of calling AdjustPlayerHP(&player[2], -10), you'd call player[2].adjustHP(-10), and &player[2] is implicitly passed as the first argument of the function. And as you can see inside the function, you can access member variables like they're locals, rather than having to put player-> before them. And when setDead() is called, the implicit this pointer is passed along to it as well.

2

Share this post


Link to post
Share on other sites


All variables are stored somewhere in memory. Different variable types (char, int, float, double) are different sizes, but all pointers are the same size (4 bytes) because they all just store the address of another variable. The pointer type tells the compiler how to interpret the data at that address.

 

DekuTree64, with a name like that, I'd expect you to use 8 byte pointers.

0

Share this post


Link to post
Share on other sites

 


All variables are stored somewhere in memory. Different variable types (char, int, float, double) are different sizes, but all pointers are the same size (4 bytes) because they all just store the address of another variable. The pointer type tells the compiler how to interpret the data at that address.

 

DekuTree64, with a name like that, I'd expect you to use 8 byte pointers.

 

Nah, 640K ought to be enough for anybody laugh.png

1

Share this post


Link to post
Share on other sites


This is all great and I enjoy programming but I REALLY want to start working with graphics and move towards 2d games. I've started to look into libraries like SDL and some of it looks really weird and then other parts I can understand. Usually after I get past the initial "setting up the SDL screen" tutorial it gets way advanced and I lose it. I really want to start moving into something with graphics because it's starting to feel like the console just isn't doing it for me anymore. With what I've learned, I have been able to program a decent text based RPG.

 

 

Learn basics.  Start small.  Make games like pong, galaga, asteroids, tetris.  Once you can do those... you'll be ready to move on to bigger things.

Patience.

 

I agree with IcedCrow on this one. Especially the part about "Patience".

0

Share this post


Link to post
Share on other sites

RPG is not the "most difficult genre", it's probably the most scalable one in term of difficulty since you can do a quite basic RPG.

Your quite on mark, i should have given it a second thought, my apologies.

0

Share this post


Link to post
Share on other sites

Okay, so after spending like a total of 20 hours studying through and using pointers/classes I've got a rough understanding of both concepts (stronger in pointers).  I'm not as worried about classes as is, but if it was required to I could understand basic things about what's going on in the class.  I'm having a problem on tutorial #2  of the LazyFoo series.

http://lazyfoo.net/SDL_tutorials/lesson02/index.php

 

It's where you start blitting an image on another image.  Why does he write all the code to optimize the image?  If use all 32 bit graphics do you even need to do that?  

 

Thanks!

0

Share this post


Link to post
Share on other sites

I would suggest taking a look at SFML as well. I tried both SDL and SFML and I liked SFML more. SFML in my opinion is easier to learn and get started with, as least that was the case for me.

0

Share this post


Link to post
Share on other sites

I agree with ZwodahS. SFML is much easier to use and is nice and OO and you don't have to include a bunch of add-on libraries to do simple things like drawing shapes and sound.

0

Share this post


Link to post
Share on other sites

It's where you start blitting an image on another image. Why does he write all the code to optimize the image? If use all 32 bit graphics do you even need to do that?

Thanks!

I think in Lazyfoo's case he was using 24 bit and converting them to 32. He wants his surfaces to be the same format as the frame buffer so it copies faster.

http://sdl.beuc.net/sdl.wiki/SDL_DisplayFormat
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