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…
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.
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!
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.