Jump to content

  • Log In with Google      Sign In   
  • Create Account


OK, This is getting big, and sloppy - any ideas?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 CainJ   Members   -  Reputation: 102

Like
0Likes
Like

Posted 20 December 2012 - 08:17 PM

OK..
My little summer project has gotten bigger than I thought
small history: ITS A remake of a well known BBS game LORD - there are many ported to the web via java and telnet, but I wanted a true Browser based game of it - and since I could not find one, I made one - note: I am aware of the LOTGD, its not quite the same) I've been in contact with the original author of the game, and since he sold it, he cannot give me any details of the game but he does like what I have done so far. - I am currently waiting for the new owners to write back, and if they pitch a fit, i'll make some changes - after all, it is more of a personal project than a public on - ergo i WANT TO FINISH IT LOL (I would say it is over 85% done - it is winnable as well - yes end game is completed)

So it has gotten, well, actually its kinda HUGE!! I a still have parts to add. Writing in PASCAL is differnt than writing in php/html (I know 7 languages pretty well, so conversion is not an issue) Without getting into details - not the purpose of my post The issue I am having is organization. I have about 80 some files 3/4 of which are templates
Basic psuedo code is as follows

everything is run from the index.php.
depending on users location, session vars and REQUEST vars, it will branch to various functions.
some examples:

index.php
as is will be treated as a user logging on

index.php?q=inn
branches to a displayInn function (with more options in there) and displays it accordingly.


casting a skill/spell? no prob
index.php?q=fght&s=sid (fighting, using skill reference sid=skill id)

and so forth.


my question, is I think my organization is all wrong, because now its starting to get cluttered. I comment HEAVY!! so what things are doing is not the issue. is "squeezing things in that is becoming an issue.

So need a little help on the organization part (programming I got)
I know there is a HUUUUGGGEEE debate on OOP vs FUNCTION (procedural) programing, so to avoid THAT debate, I am partial to the FUNCTION method for this prticular project. So no debates please. Unless you can prove without a doubt - that is the way to go.

Some Ideas I was thinking is group each location individually and then options that go with those (example fighting location gives options RUN, FIGHT, SKILLS etc..., then those will branch off to different functions to yeild outcomes.) town, same thing, each town has sub menus branching etc...


Love to hear some different idea. On the outside, the game plays quite nicely - but its the internal programming that is very ugly.

want to check it out - http://lotrd.sytes.net (its alpha and buggy, but there are no wipes - even if i change the name and format due to legalities) but look at it from a programers point of view. its very "kludgy"

hope to hear some organization details

Sponsor:

#2 LorenzoGatti   Crossbones+   -  Reputation: 2511

Like
0Likes
Like

Posted 21 December 2012 - 03:16 AM

What exactly is ugly and cluttered? Can you point out some part of your code that could be rewritten in a better style? What would you need to change to make that better style possible?

The only generic advice that applies to your high-level and fairly vague description is that using functions to display different page bodies in a single PHP file is unnatural; you can use different URLs for separate PHP pages and use templates, inclusion of page parts etc. to minimize duplication. A natural page-oriented structure lets you write more reusable functions: for example, not a presumably large and brittle displayInn function that builds most of the page but many small single-responsibility data accessors and modifiers like listInnGuestNames or getInnBeerPrice or reserveRoom that can be easily used in forms and templates.
Produci, consuma, crepa

#3 Poigahn   Crossbones+   -  Reputation: 516

Like
0Likes
Like

Posted 23 December 2012 - 09:26 AM

Okay - Break out the paper and pencil. I think a top down / decision option tree is appropriate here. Build a road map for your programs decision process. I think you may find that some of your decisions are going to cross one another eventually. But every driving trip has a starting point and an ending point. There will be a time, with so many Travelers out there that their paths will eventually cross. This might help you simplify your code.

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!


#4 Poigahn   Crossbones+   -  Reputation: 516

Like
0Likes
Like

Posted 23 December 2012 - 09:32 AM

My second comment is seperate because it is more of a question I have on OOP.
Maybe I have been away from the learning table to long and some things have changed, but is OOP not anything more than the simplification of routinely used to the point where it can be utilized over and over again from one project to another.
Correct me if I am wrong, ( as I am certain someone will, and I hope so ) but once I learn how to play poker in a simple poker program, then I want to write a casino game, why would I want to write another poker program routine. Would not that initial poker program be considered OOP for my new Casino Program, portable code ? Portable Functions ?

Sincerely Dazed and confused by the post.

Your Brain contains the Best Program Ever Written : Manage Your Data Wisely !!


#5 nobodynews   Crossbones+   -  Reputation: 1761

Like
0Likes
Like

Posted 23 December 2012 - 10:08 AM

My second comment is seperate because it is more of a question I have on OOP.
Maybe I have been away from the learning table to long and some things have changed, but is OOP not anything more than the simplification of routinely used to the point where it can be utilized over and over again from one project to another.
Correct me if I am wrong, ( as I am certain someone will, and I hope so ) but once I learn how to play poker in a simple poker program, then I want to write a casino game, why would I want to write another poker program routine. Would not that initial poker program be considered OOP for my new Casino Program, portable code ? Portable Functions ?

Sincerely Dazed and confused by the post.

That's not OOP. You can reuse code in any language, it doesn't make that language OO. It's OOP when you associate a group of data with functions that manipulate that data (methods). Some languages provide build-in support for OOP, like C++, Java, and C#. A person writing in C can make an object-oriented program it's just not directly supported by the language. Good OOP meets the SOLID principles (  http://en.wikipedia.org/wiki/SOLID_%28object-oriented_desgn%29 ) which are principles to help make OO code more easily maintainable and extandable. There are also sub-design methodologies someone can use when programming in OOP. Like "Composition over inheritance" ( http://en.wikipedia.org/wiki/Composition_over_inheritance ).

 

Because code re-use isn't related to any one language it's possible to fail to write re-usable code in an OOP language. You mention a poker program. If you write the program well then you can re-use the code in more programs but if you write it poorly then you'll have more difficulty re-using it. For example maybe you wrote a program for texas hold'em style poker and then you wanted to add a new form of poker such as five card draw. The AI for these games is likely to be very different so if you made too many assumptions in your texas hold'em program you'd have a difficult time sharing code with the five card draw program.


C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#6 Blind Radish   Members   -  Reputation: 355

Like
0Likes
Like

Posted 27 December 2012 - 01:02 PM

Try to isolate everything into a hierarchy, grid, or other logical space.

Make a diagram of you're code.  Box everything in.  Build simple lines of communication between locations that should communicate.  Keep everything that you can as isolated as possible.  If A needs B to affect C, A should never really talk to C.

Combat file, Rendering file, Character file, Map files... keep it all separate.  The goal is to get a bunch of little, uncluttered projects to play nicely together, basically.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS