Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Looking for [programming] help!

  • 25-08-2014 3:47pm
    #1
    Registered Users, Registered Users 2 Posts: 32


    The app I'm working on's code is basically garbage.
    It's got to the point where it's become almost impossible to work on and even though it's nearly finished I've made my mind up to do a rewrite. At least I'll end up with something which I can be proud of in the end, which is important since this is more of a portfolio piece than a game I'm looking to make a buck off of.

    However I'm really not sure how I can improve on what I've got. Maybe someone can help?

    The game is a variation on the board game Risk (very similar to the flash game Dicewars). Where you fight against the AI or other human players to gain control of all the regions in an island.

    The island generation makes each region an instance of a class which keeps track of the units in that region (which are clumsily stored on a separate layer), it's adjacent regions, and the team which controls it. The units are an instance of another class, which keeps track of the team it belongs to, and which region it's in right now. There are a set of variables floating around which keep track of which players turn it is, which 'stage' of the turn it is (placing units, attacking, ect.). These are used in what is essentially a series of nested if statements at the start of a turn which will call methods to take care of the turn depending on if it's an ai player or a human player, allocating some units which can be placed.

    Even that doesn't properly tell the story of all the randomly named variables which do things I've long forgotten, or the 800 lines of 'misc.' methods....
    I'm sure there's a clever way to structure this whole thing so everything can be all neat and tidy. The whole thing is in obj-c and cocos2d (An ios framework, takes care of simple stuff like loading and unloading images, animations, so you don't have to touch that nasty opengl.) if that makes any difference.

    I've heard trying to have a clear model, separate from the visuals, is a good idea. However that's kinda hard when it's split up into 40+ regions divided into 4-5 civilisations.

    Thanks in advance! :)
    -Oisin


Comments

  • Registered Users, Registered Users 2 Posts: 7,183 ✭✭✭witnessmenow


    When you say "nearly finished" , how nearly finished is it?

    My opinion on this varies pretty largely from the norm I think, but if it aint broke dont fix it (for the moment).

    Unless it is prohibiting you from finishing the game, save the re-factor/re-write til after you release. You will hopefully learn more about what users want/like out of your game, which you can rake into consideration when you re-write.

    Finishing a game is the hard part. I am not in the game dev industry , I'd imagine having a released game is worth a lot when going for jobs.

    Getting it out there is hard, putting the thing you put all this effort into in front of people is not easy, refarctoring is sometimes used as a safe choice.

    If your game is fun, as an end user I dont care if you have one giant method in a single file, if you used numbers as your variable names, all of that stuff is not important once the game is released and working correctly!

    EDIT: I would keep this lesson with you though, learn for the next time. There is basically no scenarios where you shouldn't label variables/methods something logical the first time around. Maybe even throw in a comment or two :)


  • Registered Users, Registered Users 2 Posts: 454 ✭✭Kilgore__Trout


    Maybe you could start with working on the naming of the variables & methods to enhance the code clarity, and pave the way for further work?

    It may also be worthwhile looking for a few tutorials for tile based games, as you are likely to pick up a few tricks on how others go about structuring a game of this type?

    This tutorial is for Unity, (https://www.youtube.com/watch?v=bpB4BApnKhM&list=PLbghT7MmckI4qGA0Wm_TZS8LVrqS47I9R) and near the end of the series, it does go into splitting the data and visual layers. Unfortunately, it probably doesn't place enough emphasis or go into enough detail in the area you're interested in to be of much use.

    Good luck, and keep us posted on how you get on!


  • Registered Users, Registered Users 2 Posts: 32 oisincar


    Thanks for the advice guys!

    Maybe I'll try and bash this one out on it's shady foundation, then go back and teach myself some better practices. I do have a few programming books I really need to read.

    I might've exaggerated a *little* bit on how bad the code is. The names of methods and variables aren't too bad, but when i compare it to code written by someone who knows what they're doing, its defiantly kinda clumsy.

    My game isn't tile based, but after you mentioned the idea of finding a tutorial I managed to find an open source version of risk called Domination which is something I'll have a dig around.

    Thanks again for your help! I'll keep you posted on my not-progress.
    Oisin.


Advertisement