Jump to content

  • Log In with Google      Sign In   
  • Create Account


Wanting to build a 2d RPG but kind of lost


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
15 replies to this topic

#1 drakogate   Members   -  Reputation: 104

Like
0Likes
Like

Posted 21 July 2013 - 11:30 AM

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!



Sponsor:

#2 Plutonium   Members   -  Reputation: 349

Like
0Likes
Like

Posted 21 July 2013 - 12:09 PM

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 ;)  if you will try, and later same guy have more tuts 



#3 ScottK   Members   -  Reputation: 255

Like
0Likes
Like

Posted 21 July 2013 - 12:10 PM

You sound a lot like me.

 

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



#4 ultramailman   Prime Members   -  Reputation: 1561

Like
2Likes
Like

Posted 21 July 2013 - 12:23 PM


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.



#5 BaneTrapper   Members   -  Reputation: 1140

Like
0Likes
Like

Posted 21 July 2013 - 01:10 PM

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.


Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#6 Dunge   Members   -  Reputation: 405

Like
2Likes
Like

Posted 21 July 2013 - 04:45 PM

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.



#7 IcedCrow   Members   -  Reputation: 264

Like
1Likes
Like

Posted 21 July 2013 - 06:21 PM

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.


For more on my wargaming title check out my dev blog at http://baelsoubliette.wordpress.com/

#8 DekuTree64   Members   -  Reputation: 972

Like
2Likes
Like

Posted 21 July 2013 - 06:57 PM

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.



#9 Pink Horror   Members   -  Reputation: 1115

Like
0Likes
Like

Posted 21 July 2013 - 08:34 PM


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.



#10 DekuTree64   Members   -  Reputation: 972

Like
1Likes
Like

Posted 21 July 2013 - 09:05 PM

 


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



#11 Alpha_ProgDes   Crossbones+   -  Reputation: 4688

Like
0Likes
Like

Posted 21 July 2013 - 11:36 PM


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".


Beginner in Game Development? Read here.
 
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
 
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image
 
Spoiler

#12 BaneTrapper   Members   -  Reputation: 1140

Like
0Likes
Like

Posted 22 July 2013 - 07:32 AM

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.


Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/


#13 drakogate   Members   -  Reputation: 104

Like
0Likes
Like

Posted 23 July 2013 - 08:12 AM

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!



#14 ZwodahS   Members   -  Reputation: 470

Like
0Likes
Like

Posted 23 July 2013 - 12:14 PM

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.


Check out my blog at zwodahs.github.io

Also, check out my first game on play store =D https://play.google.com/store/apps/details?id=com.on.msq


#15 Dante12129   Members   -  Reputation: 1007

Like
0Likes
Like

Posted 23 July 2013 - 03:22 PM

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.



#16 noobsauce   Members   -  Reputation: 101

Like
0Likes
Like

Posted 23 July 2013 - 03:30 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS