News: 11 March 2016 - Forum Rules

Author Topic: Space games in C++ [old projects]  (Read 5132 times)

InfamousKnight

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
Space games in C++ [old projects]
« on: February 14, 2013, 04:37:39 pm »
So I made 2 space games. One where you collect points on a field(not complete but shouldn't be too hard to complete), and one where you dodge asteroids with some HP to keep you alive(which is complete with VERY ugly code).
Here's the one with collecting points:
http://pastebin.com/xmsH9P0Z

And here's that one with dodging:
pastebin.com/8ePwGLWP

Sorry about the big indent in the beginning of each line. It happens when you copy and paste code from another site which was just for backup purposes.

Pennywise

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 2409
  • Prepare thyself for holy judgment
    • View Profile
    • Yojimbo's Translations
Re: Space games in C++ [old projects]
« Reply #1 on: February 14, 2013, 04:57:41 pm »
The point of the programming board is so that people can get help with various aspects of programming. I really don't know what you aim to achieve by making this thread, but it serves no useful purpose. Please stop doing this for all that is sacred and holy for he that blasphemies here shall be condemned to hell for all of eternity.

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Space games in C++ [old projects]
« Reply #2 on: February 14, 2013, 05:28:33 pm »
Oh dear, just reading that code temporarily reduced my programming skill.

Your initialization loops are redundant. Your use of the system function makes me want to hit you. Your abuse of the array for storing positions of simple items makes me wonder if you even thought at all when deciding how to store the data. And the fact that it's a text mode realtime game makes me wonder if you are just lazy or also incompetent. The fact that you didn't use proper console control functions point towards the later.

LostTemplar

  • Hero Member
  • *****
  • Posts: 910
    • View Profile
    • au-ro-ra.net
Re: Space games in C++ [old projects]
« Reply #3 on: February 14, 2013, 07:01:47 pm »
Never use goto unless you know what you're doing.

Learn how to use your data structures and programming constructs. That redundant code in the second pastebin is horrible.

Also, it seems you've never done anything bigger than those small programs. Stick with something and write something more functional. This will teach you how to think more structured when programming.

By the way, that's not "C++". With the exception of std::cout (and that doesn't even count as it's just a glorified printf) I don't see you using anything related to C++. Read up on object-oriented programming and the STL (plus templates in general) to improve your programming. Or stick to C, but then don't call it C++.

But, as you probably aren't going to listen anyway, stop creating threads so useless.

KaioShin

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 5699
    • View Profile
    • The Romhacking Aerie
Re: Space games in C++ [old projects]
« Reply #4 on: February 15, 2013, 04:06:14 am »
Where did you learn "programming"? C books from 1995? Geocities websites from 1993? That second code especially makes me cry just from looking at it.
All my posts are merely personal opinions and not statements of fact, even if they are not explicitly prefixed by "In my opinion", "IMO", "I believe", or similar modifiers. By reading this disclaimer you agree to reply in spirit of these conditions.

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Space games in C++ [old projects]
« Reply #5 on: February 15, 2013, 07:26:00 am »
Oop is your friend. Learn how to program using classes it makes the code look so much more organised.

Gemini

  • Hero Member
  • *****
  • Posts: 2026
  • 時を越えよう、そして彼女の元に戻ろう
    • View Profile
    • Apple of Eden
Re: Space games in C++ [old projects]
« Reply #6 on: February 15, 2013, 08:46:09 am »
OOP is perfect not just for code clarity, but also for building complex stuff like generic frameworks. Get to write a decent pack of classes and you can really improve  your applications in a totally unexpected manner.
I am the lord, you all know my name, now. I got it all: cash, money, and fame.

InfamousKnight

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
Re: Space games in C++ [old projects]
« Reply #7 on: February 15, 2013, 10:20:24 am »
First of all, that second space game was when I was in like 9th grade and I started from batch to c++ and thats why I used goto.

The ONLY reason why you would use goto is for breaking out of nested loops. I never use classes because I'm just not used to them. 'sides, what difference would it make? I think arrays work just fine when it comes to those situations. In that second game that was older, I didn't know about arrays yet. I used cursor position which wasn't very fun. That space game with dodging has got to be my most ugly code I've written. That's why I remade it. A reason why I don't like java is because its freakin ALL OOP. And organized code is important for expanding it later on. But theres no reason to expand that 1 level game. I'm surprised srand() being called twice didn't stay the same. I'm also pretty surprised by how fast it runs on some machines. I could make that remake more faster if I used cursor position and arrays mixed. And not use system("cls") to make things quicker.

KC

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Re: Space games in C++ [old projects]
« Reply #8 on: February 15, 2013, 11:08:15 am »
And for some unfathomable reason you still think that the worst code you ever wrote - which is quite a feat given what you've shown so far - would be of use or interest to anyone else. All that, of course, while never acknowledging any sort of criticism and in fact never listening to anything.

KaioShin

  • RHDN Patreon Supporter!
  • Hero Member
  • *****
  • Posts: 5699
    • View Profile
    • The Romhacking Aerie
Re: Space games in C++ [old projects]
« Reply #9 on: February 15, 2013, 11:11:23 am »
I never use classes because I'm just not used to them.

If you never use classes you will never get used to them.

See the  paradox?

Also anything Kingcom already said.
All my posts are merely personal opinions and not statements of fact, even if they are not explicitly prefixed by "In my opinion", "IMO", "I believe", or similar modifiers. By reading this disclaimer you agree to reply in spirit of these conditions.

creeperton

  • Hero Member
  • *****
  • Posts: 604
    • View Profile
.
« Reply #10 on: February 16, 2013, 01:25:40 am »
.
« Last Edit: November 16, 2015, 01:22:04 am by creeperton »

Pikachumanson

  • Hero Member
  • *****
  • Posts: 607
    • View Profile
Re: Space games in C++ [old projects]
« Reply #11 on: February 16, 2013, 01:31:32 am »
I love infamous knight's programming threads too. The guy is a total masochist when he's not too busy stalking Lugia's every move.