Homebrew RELEASE game-example - console mode game

Dontwait00

Unknown
OP
Member
Joined
Sep 3, 2017
Messages
272
Trophies
0
Age
31
XP
701
Country
Italy
game-example v1.0.0 (updated on 11/09/2018)


what is it?
first, is my first game im creating in C.
second, is a game made entirely on CONSOLE MODE with no graphics and no sound. I will create a GTA style game in 2D in the near future.


CONTROLS:

UP = up
RIGHT = right
DOWN = down
LEFT = left

A = Unknown still


game-example must do/finish:
•add gun
•add life
•add zombies
•add touch screen support (which i want to try this, so you can play it without joycons!)
•port on Wii: see here
•port on WiiU
•port on Xbox 360

How did you start developing this? :huh:
Heh, wasn't simple for me.

I started developing on useless programs, and i wanted to start something less useless to help others noob like me to try coding.
so then i started developing from scratch, using printf and other basic codes just to see want i could do.
And then i thought, if i could make a player to move up, down, left, right using variables.

My idea (which wasn't after i know it) was to use the rows and column as a player to move free
here's a concept:
lets make a simple room 8x8:
W = wall
f = floor
P = player

.....r_o_w_s
c 0...1..2..3..4..5..6..7
o..1 W W W W W W W
l...2 W f...f...f...f...f...W
u..3 W f...f...f...f...f..W
m.4 W f...f...f...f...P..W
n..5 W f...f...f...f...f..W
....6 W f...f...f...f...f...W
....7 W W W W W W W

if i press up = [3][6] = floor, which means i can move
if i press right = [4][7] = wall, which means i cant move there
if i press down = [5][6] = floor, which means i can move
if i press left = [4][5] = floor, which means i can move
Now, after a bit of theory, we need practice on it.
Lets start:
...
// now lets start using int as variables
int a, b;

//then i need to operate like this to use rand()
srand(time(NULL));

//now i can use rand() to rand some numbers
a = rand() % 10;
b = rand() % 20;

//now i can assemble a and b to be the player.
//\x1b[r;cH is for printing on the screen where you want,
//which r stands for Rows and c for Columns
printf("\x1b[%d;%dHx", a, b);

//lets start doing the player move!
if (kDown & KEY_DUP) {
//now that we printed the player, we need to delete the footstep behind him
printf("\x1b[%d;%dH ", a, b);
a = a - 1;
//now lets move the player up!
printf ("\x1b[%d;%dHx", a, b);
}
//now we have to do this step every single step for every direction pad.
if (kDown & KEY_DDOWN) {
// so on
...
}
Now we can move the player UP, DOWN, RIGHT and LEFT.
But we still need the collision like the wall!
lets start:
...
//we need to compare the collision with a wall called X,
//so we need a new int
int wall_y;
int wall_x;

wall_y = 10;
wall_x = 10;

if (kDown & KEY_DUP) {
if (a == wall_y && b == wall_x) {
a = a + 1;
printf ("\x1b[%d;%dHX", wall_y, wall_x);
printf ("\x1b[&d;%dHx", a, b);
}
}
//so on with every direction pad
...
I hope i helped you, if so, feel free to drop a like!:creep: thanks

i may written badly somewhere, feel free to DM me, thanks

changelog:
v0.1 - added player moving on screen; bugs everywhere

v0.3 - added collision! (was my first time using logic interpreters)
- fixed minor bugs, still a lot of bugs!

v0.5 - added wall using collision! (those XXXX are walls ;P)

v0.7 - fixed all the bugs like:
1) numbers printed on screen when touching end of the screen;
2) player disappearing from the screen;
3) collision worked only from the front of the player;
4) player now cant get out of the screen using collision.
5) ???
6) profit

v1.0.0 - just everything fixed

Download: https://github.com/Dontwait00/game-example/releases/latest
 
Last edited by Dontwait00,
D

Deleted-442439

Guest
game-example v0.7 (updated on 10/09/2018)


what is it?
first, is my first game im creating in C.
second, is a game made entirely on CONSOLE MODE with no graphics and no sound. I will create a GTA style game in 2D in the near future.


CONTROLS:

UP = up
RIGHT = right
DOWN = down
LEFT = left

A = Unknown still


game-example must do/finish:
•add gun
•add life
•add zombies
•add touch screen support (which i want to try this, so you can play it without joycons!)
•port on Wii
•port on WiiU
•port on Xbox 360

How did you start developing this?
Heh, wasn't simple for me.

I started developing on useless programs, and i wanted to start something less useless to help others noob like me to try coding.
so then i started developing from scratch, using printf and other basic codes just to see want i could do.
And then i thought, if i could make a player to move up, down, left, right using variables.

My idea (which wasn't after i know it) was to use the rows and column as a player to move free
here's a concept:
lets make a simple room 8x8:
W = wall
f = floor
P = player

.....r_o_w_s
c 0...1..2..3..4..5..6..7
o..1 W W W W W W W
l...2 W f...f...f...f...f...W
u..3 W f...f...f...f...f..W
m.4 W f...f...f...f...P..W
n..5 W f...f...f...f...f..W
....6 W f...f...f...f...f...W
....7 W W W W W W W

if i press up = [3][6] = floor, which means i can move
if i press right = [4][7] = wall, which means i cant move there
if i press down = [5][6] = floor, which means i can move
if i press left = [4][5] = floor, which means i can move

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// now i started using int as variables
int main() {
int a, b;

//then i need to operate like this to use rand()
srand(time(NULL));

//now i can use rand() to rand some numbers
a = rand() % 10;
b = rand() % 20;

//now i can assemble a and b to be the player.
//\x1b[r;cH is for printing on the screen where you want,
//which r stands for Rows and c for Columns
printf("\x1b[%d;%dHx", a, b);

//so on
}
sorry but i havent much time now, so i will finish as soon as possible :(
changelog:
v0.1 - added player moving on screen; bugs everywhere

v0.3 - added collision! (was my first time using logic interpreters)
- fixed minor bugs, still a lot of bugs!

v0.5 - added wall using collision! (those XXXX are walls ;P)

v0.7 - fixed all the bugs like:
1) numbers printed on screen when touching end of the screen;
2) player disappearing from the screen;
3) collision worked only from the front of the player;
4) player now cant get out of the screen using collision.
5) ???
6) profit

Good job! Keep learning and trying new things, you will soon be able to create more advanced stuff, always nice to see people that are willing to learn.
 

Dontwait00

Unknown
OP
Member
Joined
Sep 3, 2017
Messages
272
Trophies
0
Age
31
XP
701
Country
Italy
Nice! Have you coded in C before?
I know some C# but no C.:(
Not really, no :(

What i like about C is that you can make it for every OS with just few steps which is awesome! I like program in C, but never did such a big project like this, so im looking forward for this!

Don't you like C? I thought C# was much more difficult then C.
 

lordelan

Well-Known Member
Member
Joined
Jan 4, 2015
Messages
5,798
Trophies
1
Age
44
XP
6,561
Country
Germany
I thought C# was much more difficult then C.
I'd say C# is one of the easiest to learn languages out there lol.
Great work by the way. It was wise to share your work here. As you can see everyone appreciate it although they probably won't stop playing Splatoon for it but it's a good entry. :)
 
  • Like
Reactions: Dontwait00

Dontwait00

Unknown
OP
Member
Joined
Sep 3, 2017
Messages
272
Trophies
0
Age
31
XP
701
Country
Italy
I'd say C# is one of the easiest to learn languages out there lol.
Great work by the way. It was wise to share your work here. As you can see everyone appreciate it although they probably won't stop playing Splatoon for it but it's a good entry. :)
i thought of it, but i like coding and i dont mind people playing it or not. This is just basic project.
(which now i have released 1.0.0 finally, so if you want to see it is here: https://github.com/Dontwait00/game-example/releases) :ha:
 
  • Like
Reactions: lordelan

Jay Griggs

Active Member
Newcomer
Joined
Jan 4, 2016
Messages
34
Trophies
0
Age
42
XP
772
Country
United States
Never did C so I cant compare.
Got friends that do C and they say the biggest differences are that C# is object oriented, C# handles all your garbage collection and with C you need to include your headers.
 

Kevoot

Well-Known Member
Newcomer
Joined
May 23, 2018
Messages
67
Trophies
0
Age
40
XP
430
Country
United States
To OP: It's a good start. You should pick up the book (or steal the PDF) "Introduction to Algorithms"
Link: https://mitpress.mit.edu/books/introduction-algorithms-third-edition

Additionally, do some research into using data structures in C. I can see that you have an idea to establish rules and turn that into code which is the first step. The next step is to define the code in a reuseable, readable, and less-time consuming way (both in terms of running time and how long it takes to write). You have a ton of repeated code which is overkill and leads to a litany of issues, those two resources will get you going in a better direction.

For reference, if you look up my github account and find my checkers3ds, that was where I was at about 4 years ago. Comparing that to the code I write these days makes my butthole clench. Do yourself the favor and look into those topics.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Xdqwerty @ Xdqwerty:
    good night
  • BakerMan @ BakerMan:
    as to you
  • K3Nv2 @ K3Nv2:
    How do you know if the night will be good when you're asleep
  • BakerMan @ BakerMan:
    because i didn't say i was asleep
  • BakerMan @ BakerMan:
    i said i was sleeping...
  • BakerMan @ BakerMan:
    sleeping with uremum
  • K3Nv2 @ K3Nv2:
    Even my mum slept on that uremum
  • TwoSpikedHands @ TwoSpikedHands:
    yall im torn... ive been hacking away at tales of phantasia GBA (the USA version) and have so many documents of reverse engineering i've done
  • TwoSpikedHands @ TwoSpikedHands:
    I just found out that the EU version is better in literally every way, better sound quality, better lighting, and there's even a patch someone made to make the text look nicer
  • TwoSpikedHands @ TwoSpikedHands:
    Do I restart now using what i've learned on the EU version since it's a better overall experience? or do I continue with the US version since that is what ive been using, and if someone decides to play my hack, it would most likely be that version?
  • Sicklyboy @ Sicklyboy:
    @TwoSpikedHands, I'll preface this with the fact that I know nothing about the game, but, I think it depends on what your goals are. Are you trying to make a definitive version of the game? You may want to refocus your efforts on the EU version then. Or, are you trying to make a better US version? In which case, the only way to make a better US version is to keep on plugging away at that one ;)
  • Sicklyboy @ Sicklyboy:
    I'm not familiar with the technicalities of the differences between the two versions, but I'm wondering if at least some of those differences are things that you could port over to the US version in your patch without having to include copyrighted assets from the EU version
  • TwoSpikedHands @ TwoSpikedHands:
    @Sicklyboy I am wanting to fully change the game and bend it to my will lol. I would like to eventually have the ability to add more characters, enemies, even have a completely different story if i wanted. I already have the ability to change the tilemaps in the US version, so I can basically make my own map and warp to it in game - so I'm pretty far into it!
  • TwoSpikedHands @ TwoSpikedHands:
    I really would like to make a hack that I would enjoy playing, and maybe other people would too. swapping to the EU version would also mean my US friends could not legally play it
  • TwoSpikedHands @ TwoSpikedHands:
    I am definitely considering porting over some of the EU features without using the actual ROM itself, tbh that would probably be the best way to go about it... but i'm sad that the voice acting is so.... not good on the US version. May not be a way around that though
  • TwoSpikedHands @ TwoSpikedHands:
    I appreciate the insight!
  • The Real Jdbye @ The Real Jdbye:
    @TwoSpikedHands just switch, all the knowledge you learned still applies and most of the code and assets should be the same anyway
  • The Real Jdbye @ The Real Jdbye:
    and realistically they wouldn't

    be able to play it legally anyway since they need a ROM and they probably don't have the means to dump it themselves
  • The Real Jdbye @ The Real Jdbye:
    why the shit does the shitbox randomly insert newlines in my messages
  • Veho @ Veho:
    It does that when I edit a post.
  • Veho @ Veho:
    It inserts a newline in a random spot.
  • The Real Jdbye @ The Real Jdbye:
    never had that i don't think
    The Real Jdbye @ The Real Jdbye: never had that i don't think