• Forum
  • Lounge
  • My Ongoing Struggles in Making a C++ Gam

 
My Ongoing Struggles in Making a C++ Game

I just want to give a short story of my attempts at learning how to program and what I do today in the realm of programming.

My motivation for writing code was originally to learn how make GameBoy games in 2014, ninth grade. However, I never caught on with learning C++ for some reason and it was until around July 2016 that I really began to learn about C++, with the interest in making an online game.

Much of my childhood consisted of these two rotten MMO's called RuneScape and MapleStory, with countless hours wasted on their glory. Just a few months prior, I revisited the latter game on a private server running a version from 2008. Combined with the fact that I didn't have friends during highschool, it really hit me hard with nostalgia.

It came to me that I wanted to make a game that stimulates that very feeling of being a noob and making mistakes. I paid my soul for those games so it only made sense that I get it back by making people play my game!!! Nah, that would be cruel and beyond my ability.

So my first thought of making a game came around as a cross between the gameplay of MapleStory and RuneScape, both of which are RPG games, MapleStory being an unforgiving 2D side scroller and the other being an overhead slow action laggy square tile game.I liked the elements of those 2 games. At home and at the school library computers during lunch break (I needed a girlfriend), were the places of learning the basic syntax and features of the language. I'd also push my limited knowledge to the limits and produce barely functional programs that would be focused on aspects of the game.

It would be in January/February 2017 that I wrote code like this

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
char *DISPLAY = new char[4000];
initiate(DISPLAY);
int cursor = 0;

int saveData[DATA_SIZE] = {};
Character player;

char **mapSprite;
mapSprite = new char*[MAPSPRITE_SIZE];
for(int count = 0; count < MAPSPRITE_SIZE; ++count)
	mapSprite[count] = new char[10];
char **characterSprite;
characterSprite = new char*[CHARACTERSPRITE_SIZE];
for(int count = 0; count < CHARACTERSPRITE_SIZE; ++count)
	characterSprite[count] = new char[10];


whose program would look like this:
















                                        +  +  +
                                       +++++++++
                                        +  +  +
                                        +
                                       +++
                                        +
                                        +
                                       +++
                                        +
                                     +  +
                                    ++++++
                                     +  +
                                     +
                                    +++
                                     +
                                     +
                                    +++
                                     +
                                     +    iO
                                    +++   lHl
                                     +     M
                                     +
                                    +++
                                     +
                                     +
                                    +++
                                     +
                                     +
                                    +++
                                     +






The above is a screenshot of a program I wrote in February 2017 on the console window. It used file i/o to load the sprites and map layouts. Each 16x15 map screen has its own file named something like map0100.txt depending on the player's coordinates, similar to how the map changes in Zelda. Oh god it's already 2:36am. I think I'll continue writing this after sleeping. Next time I'll talk about my ridiculous idea of the magic physics world.
Last edited on
You know, if you're into Game Boy games and RPGs and you have plenty of free time, I have a project you might be interested interested in: https://github.com/Helios-vmg/cppred
Just sayin'.
Cool, helios, I'll look at it.
We continue yesterday's story...

There was this physics class at high school and my god I loved it. It was so much fun to do well at a subject and to watch everyone else struggle.

"In these questions, we are dealing with surfaces with no friction because we are in Mitchell's Magic Physics World..." I remember hearing the physics teacher saying something like that.

"Hmm, that would be an interesting title for a game..." I was thinking. A game about physics, literally. It would be quite hard to make a fun little game that involves answering physics questions. Maybe have some interesting dialogue with the NPC's or do something that is unique to most programs today... Ohhh boy this would be a tough basis for a game.

By March 2017, I was quite aware of the syntax of the language and stopped learning. I began to practice more on coding and developing coding habits. A lot of programs I wrote at the time were small building blocks for a rather generic top view console window RPG that used conio.h for detecting key presses. I couldn't progress much further in the game's concept because of my lack of creativity. I just wasn't naturally an abstract thinker, and I really went nowhere with the game's content.

Here is a bit of NPC dialogue from around May 2017 that just sums it all up! Don't judge me! People can change and learn so many new things in the span of 2 years!

-d What year is it now? I've been around since such a long time ago that I'm fading away.
-r What's wrong?
-r You obviously should have died earlier.

-d Can't you see? I'm deteriorating. I need something to back me up and make me last longer.
But now I can hardly move.
-r What do you need?

-d Glad you're interested in helping. Get me some iron oxide tape spools. I believe those hipsters
nearby with their cassette tapes have some. I mean, ugh! It's 2017! Can't they appreciate what
today's technology has to offer! A hard drive for a laptop is commonly 1 terabyte in capacity. Isn't
that amazing? You can also get me that some other time!

If I wanted to end up with an online game, I also needed to know more than programming with bare C++. Tune in next time for programming after high school has finished. Now I have to go sleep...
Last edited on
closed account (367kGNh0)
This is just reminding me of a book written by a man you may be suprised by:

https://www.amazon.co.uk/Mein-Kampf-Adolf-Hitler/dp/817224164X/ref=sr_1_1?keywords=mein+kampf&qid=1560284943&s=gateway&sr=8-1
The thread might be similar in title, but otherwise, the comparison to Mein Kampf is in poor taste. Didn't report you for it, though.

I'm enjoying @Mapler's story as is, and hope he(?) continues it. Always interesting to hear about people's experiences with programming.

Last edited on
Keep at it Mapler! If you still play, you can add me on osrs :) "colorfulpup"
Yeah I come on and off occasionally on osrs, on "ryanpwndu", mostly to train ranged! I'll add you the next time I come on.

Today we're going to continue the story, during my last year of the dreaded high school. Yeah, it's not a great place to be an introvert or socially awkward person. You'll get scrutinized for every little detail. But with that said, we'll be talking about things programming-related.

In the fall of 2016, I was using this website and learncpp.com to learn all about C++. It was something that I kept to myself. I didn't want to show anyone at school of what I was doing, for fear of being called out for being a novice at coding, or that my physics world idea was stupid as hell. It also didn't help that I was rather discouraged by my parents, saying that I should be focusing on my studies, and that I won't be getting anything out of programming. At the time, my own desire was my only motivation.

Around October or November, there was an intern teacher working with the main teacher in pre-calculus class. He noticed that I was studying C++ and he let me borrow a book about C, saying that although C was less flexible, it was more powerful than C++. It was really interesting to learn C and C++ at the same time, with their different programming styles. Later on he let me borrow an old book about Matlab (back when its interface was in the terminal) which unfortunately I didn't read much.

There was a computer programming course in the second semester of grade 12 (2017 spring). Instead of that, I was taking creative writing, while my Asian counterpart friend was taking a programming course. The only thing I didn't like was that the course taught Java instead of C++.

It was an empty study period near the end of the school year and I got to see a bit of what my Asian counterpart friend was doing in his computer science class. They had a final project to make a game. There was a character on a fixed screen with some monsters chasing it. It had some special attacks and lots of things that C++ couldn't do on it's own. And there I was, stuck to the terminal window, compiling applications using MinGW.

I noticed that the enemies chasing the character on the screen were impossible to dodge because they traveled at the same speed as the the player, and they would be always traveling towards the player. Using my practical experience in programming, I gave the suggestion that the enemies should be going towards a previous position of the player, so that they are a little easier to dodge. They were puzzled for why I chose to do creative writing instead of programming.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
void npc_chat_mitchell(Player* p, int response){
  switch(p->get_npc_data(0)){
  case 0:
    switch(response){
    case 0:
      ui_npc::update("Welcome, adventurer! I'm the guy who owns this place. The world we live in is in need "
      "of people who know their physics well. %r 01 NEXT");
      break;
    case 1:
      ui_npc::update("I will send you to downstairs where you can get used to the controls. By the name of "
        "physics, I shall teleport thee now! %r 02 OK %r 03 ->Wait! I have something else to do.");
      break;
    case 2:
      ui_npc::update("");
      p->set_npc_data(1 /*state*/, 0 /*index*/);
      //teleport player to map 2
      break;
    case 3:
      ui_npc::update("Oh, well sure then. Talk to me again when you want to go. %r 04 END CHAT");
      break;
    case 4:
      ui_npc::update("");
      break;
    }
    break;
  case 1:
    switch(response){
    case 0:
      ui_npc::update("Wazzup, I'm the guy who owns this place. %r 01 END CHAT");
      break;
    case 1:
      ui_npc::update("");
      break;
    }
    break;
  }
}

void npc_chat_jack(Player* p, int response){
  if(p->get_npc_data(1) == 0){
    switch(response){
    case 0:
      ui_npc::update("Oh, this is SO unfair! Why am I to be the bottom bitch and stay stuck with the beginners? "
        "%r 01 Tough luck, pumpkin pie. %r 04 Hey, I came here to learn some physics, bitch!");
      break;
    case 1:
    case 4:
      ui_npc::update("Before you have fun, it's great to know the basics at the start of any game. Just to make sure you know "
        "how to use your inventory screen, I am going to give you this apple. Now I am going to hurt you a "
        "little. %r 02 NEXT");
      p->set_npc_data(1 /*state*/, 1 /*state*/);
      //give player apple and lower HP
      break;
    case 2:
      ui_npc::update("You can access your inventory by pressing the i button by default. %r 03 END CHAT");
      break;
    case 3:
      ui_npc::update("");
      break;
    }
  }
  if(p->get_npc_data(1) == 1 /*&& player doesn't have the apple*/){
    switch(response){
    case 0:
      ui_npc::update("Ok, good, you have a brain. Here's how to attack things, which is probably one of the most "
        "important aspects of this world. Use  %r 01 NEXT");
      break;
    case 1:
      ui_npc::update("You have a wooden stick in your inventory so go select it. Then get me 3 KITTEN FUR from "
        "those kittens. You should know how to obtain them. %r 02 END CHAT");
      p->set_npc_data(2, 1);
      break;
    case 2:
      ui_npc::update("");
      break;
    }
  }
  if(p->get_npc_data(1) == 2 /*&& player has 3 kitten fur*/){
    switch(response){
    case 0:
      ui_npc::update("Good! Now my job is done. Fare well! I mean, get lost. %r 01 END CHAT");
      break;
    case 1:
      ui_npc::update("");
      break;
    }
  }
}

Now that high school was over, it would only be a matter of time I'd be going to university. Oh, when will it end? I just couldn't stand the long summer break of not doing anything. Well, I did get some work done for the physics world project, with some improved console window graphics and animated sprites. However, I was tampering with it months later and today I can't recover it. Eventually it was September again.

I was away from home during the first year of university. Unlike high school, I was immediately making friends. Wow, it's been like 10 years (actually 8), since something like this has ever happened! There wasn't that much time to do hobbies anymore, so progress slowed down.

In November 2017, I made my first attempt to do socket programming using the ws2_32 library. The goal was simple: to send a message to another program. However, I was doing something wrong and it all felt like a huge waste of time. It wouldn't be until April 2018 that I finally get sockets to work. There was some source code on Github for a MapleStory server that I often looked at, as a reference. I placed it in a folder called "Advanced_Stuff-NOT_MINE!" because I couldn't understand much of the code when I first downloaded it. I noticed that for its socket connections, it used the Boost ASIO library. That would later be what I used.

Installing and building the Boost library was very complicated, I felt, for the MinGW compiler suite. The step by step process on their own website wasn't easy for me to understand and I had to search further online for help. Sooo many compiler warnings occurred in the process and in the end, I couldn't compile programs without linker errors.

Jump back to terminal window graphics programs!

g++ camera_offset.cpp console_graphics.cpp damage_display.cpp
 demo1.cpp dragon.cpp error_report.cpp framerate.cpp key_event.cpp
 map.cpp mob.cpp player.cpp sprite_data_provider.cpp -o demo1.exe -static


                                ---/   V
                                \ /\  -v\
                                |/  \/ -/
                                /-\ /  β–‘β–’
                                   /  ||β–‘io
                                /--|| || (-
                                  -||_/|| W



HP:  15/30          EXP:      0/50


Hmm, I don't see anything physics-related in this program. It's just a player attacking a dragon, and backing away before getting hit. (It is hard to implement this action on the terminal window!)

Since I'm running out of space for this message, I will stop for now and continue later!
Man yo really did put alot of effort into it. I would suggest you to try looking into "Unity Game Engine". You can make a working rpg game with graphics etc in less than a month if you start from scratch. Its alot easier and C# languauge is similar to c++ it will help.

closed account (367kGNh0)
No need to go to C# for graphics, @Hammad Ali

Cocos2d-x is perfect for these projects. I use it, it is easy. And beats terminal graphics any day!
https://www.raywenderlich.com/2764-how-to-make-an-rpg

And it's cross platform unlike console c++.
Topic archived. No new replies allowed.