Hello, I’ve been doing more research on this topic, because I posted it, right? Gotta keep it up. I found a keyword for all those interested in this topic: “Development plan / development planning”. It’s great for people making tutorials, also, I think, because if you follow a development plan in your tutorials, you will be able to show a bunch of newbs how to make their own programs, rather than what the code looks like for a completed program. Of course, you can build a program and say, “Well, this makes a circle,” But then you’re just throwing the newb a fish. Wouldn’t you rather teach the newb HOW to fish?
So, in the next paragraph I’ll describe what I’ve found on development planning and how to go about making your own programs. Also, I think it’s great for tutorials. If you are an experienced programmer, please remember to dumb down tutorials and show us newbs your development plans with your step-by-step guides to making most excellent games.
First, you want to make a very general program that does what needs to be done, without any functions. It should sort of run by itself. It should do a part of what needs to be done in the grand scheme of things. For example, if you want to make a player jump up and down, just make a player jump up and down. Don’t do a block like
def jump(player, force, ceiling, aircontrol)
and go on with all the keys or whatever. Instead, just write:
jp(p, 6.4, 10, 2)
Or whatever, to make sure that your character jumps and test some values. Now we’re having some fun.
Second, encapsulate your program into the most basic function possible. For example:
jp(p, 7, ceiling, 2) #this is a jump value that I like, ceiling is a global variable that changes based on where the character is located
self.player1.actorInterval('jump', startFrame = 1, endFrame = 7), #jumping up for 10 frames
Func(self.checkJump, 2) #checks if the character bumped his head on the ceiling (he didn't)
self.player1.actorInterval('jump', startFrame = 8, endFrame = 14)) #falling for 7 frames
Now your function has a name and an animation. That’s nice, isn’t it? Sometimes, all your function needs is a name and an animation. If what you have defined is always going to do the same thing, all you need is a function. Functions are easy to remember, and you can use them for keypresses or whatever. If there’s a low ceiling, though, the character is going to bump his head!
So, next you want to go through “generalization”. You basically add parameters to the function. Usually, you need to go through this so you can use the jump function for different players in conjunction with animations, and you can change how high each character jumps. Stuff like that.
def jump(player, height, ceiling, aircontrol)
if height >= ceiling
height = ceiling
if height == ceiling
self.checkJump = 1
if height < ceiling
self.checkJump = 2
jp(player, height, ceiling, aircontrol)
self.player.actorInterval('jump', startFrame = 1, endFrame = height), #jumping up for height frames
Func(self.checkJump, a) #checks if the character bumped his head on the ceiling, if he did then self.checkJump should change to 1
if self.checkJump = 2
self.player1.actorInterval('jump', startFrame = height, endFrame = height * 2) #falling to the floor
if self.checkJump = 1
self.player1.actorInterval('bump', startFrame = 1, endFrame = 4)
self.player1.actorInterval('jump', startFrame = height - 4, endFrame= (height * 2) - 4))
jump(sonic, height=7, ceiling, aircontrol=4) #I'm adding keyword arguments, so you guys remember.
jump(tails, height=12, ceiling, aircontrol=6) #Arguments such as 12 and 6 work the same as height=12 and aircontrol=6, but keyword arguments are useful reminders.
Sorry, it is a little generic. ^^
The hint that I got for the generalization step that helped me the most was: ‘If your comments explain how something happens, rather than what is happening, it’s not general enough.’
So then, you just repeat and debug. My code probably needs debugging, for example. I haven’t tested it. I just used it as an example, so that you guys could see the process. It keeps a steady flow of work coming out of you, which is really fantastic.
The final step is to improve your program. This is called “refactoring”. Even the hottest programs designed by the best programmers can often be refactored. There are often generalizations that they needed which you won’t be needing, or you might want to add a new function definition that uses an old function. It’s a great way to learn and study things… to refactor.
Anyway, this is a development plan. I am still looking for more advice, so all you veterans jump in and give us some advice. I’ll try to post some more reliable codes and tutorials, soon. Okay? Peace!