My first game template (PLEASE CRITIQUE)

Hey everybody,

So basically I don’t usually ask people for critiques because my head is generally pretty comfortable up my ownass, but the time has come for me to admit that if I am going to learn to create games in C like a real developer than I need to ask the real developers (YOU ALL) for help. I am relatively new to C, but have a strong background in programming other langues JAVA/C#/etc. Basically, I want to know what standard game dev practices im doing wrong, and how I can use an better OOP type structure in C making my game. If any of you ever wanted to tear a new A-hole into somebody who is probably doing things the wrong way then look no further and gimme some feedback! I hope you all are enjoying the experience as much as I am.

I added an enemy that just goes down the Y axis, still have to work that out.

CODE-------> https://github.com/Mre64/Arudboy_Movement_Helloworld.git
VIDEO------> https://www.youtube.com/embed/vekjXgir-fE

 PS. the games title is leaning towards "the battle for zuthsrah".

        -Mre
1 Like

Could you change your entry ? We can’t read the text properly … :smile:

Also, include a video or some screenshots please :wink:

1 Like

Thanks for the tip, didn’t realize it looked that way, all is better now!

-Mre

2 Likes

I like it, this is a good start. You’ve got a player space, a player entity and some movement code. Good stuff.

Looking at the code, the first thing I notice is that the handling of player input is dealt with in the loop() function.

You may consider moving this code to a separate function. Or even better, look into making a class, or an abstract object, maybe name it Entity, that has all of the movement functions as its member functions. Then the enemies and player entities can both inherit from this base class, and save you some work.

https://en.wikibooks.org/wiki/C%2B%2B_Programming/Classes/Member_Functions

Also you have some spelling errors in your git title : ) Best to keep your repository short, as you will have to type it out from memory sometimes.

Thank you so much for your input! I will certainly look into this and the link you posted for me as soon as I finish work for the day. Once I am finished I will push my changes with your advice, thank you again it really means a lot that you would take the time help me better myself! Cheers’

-Mre

1 Like

We tend to use a “switch case” in the mainloop en keep all other code out of the main loop.

small example

void loop() {
  if (!(arduboy.nextFrame())) return;
  buttons.poll();
  arduboy.clearDisplay();
  switch (gameState)
  {
    case STATE_MENU_MAIN:
      // show the splash art
      drawMenu();
      checkMenuInputs();
      break;
    case STATE_GAME_INIT:
      initiateGame();
      gameState = STATE_GAME_PLAYING;
      break;
    case STATE_GAME_PLAYING:
      checkGameInputs();
      updateStage();
      break;
    case STATE_GAME_PAUSE:
      if (buttons.justPressed(B_BUTTON))
      {
        //afterPause();
        gameState = STATE_GAME_PLAYING;
      }
      break;
  }
  arduboy.display();
}

you’ll have to define those menu STATES

1 Like

This made me tear up a little bit :crying_cat_face: In order to know anything, you must first acknowledge that you know nothing.

3 Likes

This is true! and as they say; “pride comes before the fall”, and im sick of falling haha. thanks for the reply bateske!

-Mre