How many ways could a game be developed?

Sorry if this is a stupid question, I’ve been away from programming for a while and just got back into it.

I’m interested is there more than one way a game like pong for example could be programmed? or would it always be near enough 95% the same code (methods, libraries etc)… Excluding named variables of course hence the 95% . Lets say if it was a pong to be developed using JFrame…

Basically would there be a number of ways to code it to do that job of the classic pong? or even space invaders, tetris etc

I’d be interested to hear some feedback on this from the pros to help with my learning & confidence carrying on

I’ve also posted this question before in another java forum (not java gaming) but that was more for software, I’m interested to see what the experts have to say on here…

Thanks

You can make pong however you want. You can create it using byte code if you’re a genius or something. I mean, … Might be lame answer, but here you go.
You can create it anyhow you can / want. Might be 100% different than the original.

Too many ways …

You can always make an interpreter, e.g. simulate a toruing machine, and then invent some new syntax and semtantic just for this one project.

Even in methodologies you have many choices

  • functional
  • procedural/imperative
  • flavors of object orientation
  • logic based (fact/resolution systems)
  • self modifying/self-generating code
  • descriptive languages + scripting/interpretation

Great thanks…

I’ve noticed today that for keyboard input moving lets say a g.drawRect() on JFrame, there are many ways of using the key class to do this?

  1. How many ways from the top of your head do you think you could do this? (This will also help me on the research side to programming in java)

Also, 2. How should I start out with programming a small game like pong/breakout, would it be best if I just stick to making it in one class first?

If someone could answer these 2 questions especially the 1st one that’d be excellent personally.

  1. If you have experience with Java/Programming and know how to do basic OOP…no, split it and make it easier for yourself imo.

When I made Pong, I had 4 main classes. Player, AI, Paddle, Ball.

Despite it still being messy, it would have been a hella lot more ugly if it was in a single class.

Although you can pretty easily create it in once class with < 500 lines using a lib like LibGDX. Probably.

If we go and say that the game files can take up no more than 2 GB, then its about:
4611686018427387904 ways, in the matter of bytes that can be different.

It’s probably even more than that, because I most probably made an error in my calculation!

Have a nice day!

  • Longor1996

Okay, seems to me that you are fairly new to programming, so I’m going to try to put some perspective on coding.

Creating a game is more like drawing, or planting a seed. So, when you ask “how many different ways can you code?” You are asking “how many ways a plant can grow?”, or “how many ways you can draw a tree?” You know the answer is a number, but you can’t say what it is. It is something we can’t measure. There are numerous different ways to write “Pong”. A programmer can write it in 100 lines of code all the way 5000000 lines of code and more if they wanted to. The fact is it all depends on who you ask, and how good of a programmer the person is. There are as many ways to write a program as there are stars in the universe.

As for writing programs themselves. You always start simple. You write things in one class and expand outward from there. You can learn functions by just seeing how you can remove some code from your “main” class to make a function. When you code, the main idea is to make doing repetitive tasks easier. That is what computers were designed for. When you code, you are doing the same thing. Classes and functions are made to prevent you from having to repeat the same lines of code 40 times. The moment you are repeating code, that is when you know it is time to start using those functions.

The best way to learn how to program is to practice at it. There is a lot of information on the forums here and elsewhere on how to program. I hope this little segment broadens what programming is to you a little more.