Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / [WIP] Memory Trainer 2013, Constructive criticism on my coding style wanted

Author
Message
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 22nd Mar 2013 07:40 Edited at: 22nd Mar 2013 07:44
I've attached the source code from my next app 'Memory Trainer 2013'
Only Short Term Memory works so far, the others just end (Though I've started work on Long Term Memory, just ignore the code in it)
What I'm really looking for is Constructive Criticism on my coding style.
I never learned proper coding style, so this is basically my own way of doing it.

[Please don't use the code in your own programs, or distribute in any way, thankyou)

edit: in case anyone has downloaded Dodge those balls, and is wondering why I'm using Pen and Paper style graphics again, the reason it simple: I suffer from a serious case of programmer art and this is the only way I can pass it off!

edit2: I just realised I forgot to attach it

Attachments

Login to view attachments
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 23rd Mar 2013 00:56 Edited at: 23rd Mar 2013 00:57
Hi MissJoJo,

One thing I would suggest is to start using comments in your code. You divide various chunks of code with asterisks but I didn't see a single line of actual comments to hint at what the code blocks do. In a small app like this a lot of the code may seem self explanatory as you wrok on it, but returning to it months from now will be much easier if you have documented what the functions and such achieve.

Another area that you may wish to explore is condensing of repetitive code and making use of user defined types. For instance, rather than using unique global variable names for every single image, sprite and text object, you may consider creating a generic array or user type array to allocate and keep track of the resources. This way, you can create a for loop and within that loop you only need to make a single call to the various sprite/text positioning functions rather than copying and pasting those lines for every element. A sample of looping through such an array may be:



In this example, you would create a user-defined type that can store the sprite's id, position and color data. After creating an array of this custom type, you can give each one custom properties but still do all the positioning and sprite updating in one go. See this page for more details.

Also, if you are only using images for a single sprite, you can take shortcuts without explicitly defining the image in a separate variable. Example: mySpr = CreateSprite(LoadImage("myimg.png"))

Login to post a reply

Server time is: 2024-04-19 22:26:15
Your offset time is: 2024-04-19 22:26:15