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.

Newcomers DBPro Corner / i need an idea for my second game project and review my code

Author
Message
fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 1st Nov 2011 07:24
ok so i have a couple of things to ask of you.

Im fairly new to the programing world, and i started out going head over heels into a 2d game that i just couldnt manage. once i realized that i was in over my head i gave up on it for a bit scrapped everything i knew and decided to relearn everything. i took some time to go through tdk's tutorials im currently on #4.
it was easy seeing as how i already memorized the db language after completing the fourth tutorial i started a project call castle fight. its just a simple boring text based combat game, that i used to implement the basics i covered.

anyway here is what iv got so far. i was hoping you could read over it and critique my theory and let me know if its easy to read, structured right, and all that jazz.



its still got a couple of bugs mind you that im working out.

my next question is that i was hoping you could give me an idea of a basic 2d game i could create using just the basics. nothing too fancy just something to help me learn a little bit more.

thank you for your time.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Nov 2011 11:20
Quote: "i was hoping you could read over it and critique my theory and let me know if its easy to read, structured right, and all that jazz.
"

I think it would be worth, before continuing with this project, to learn how to use types. In short types allow variables (I call them objects) to have other variables. So lets say you have a spaceship. This ship will need x and y values as well as speed, sprite numbers, image numbers etc. So an easy way to structure all of this is to create a type. Like this:


You can also create arrays of types such as:
dim spaceships(10) as ship

One limitation of types is that you cannot have arrays within types so the following is invalid.



Once you get the hang of these I think you'll find many new ways of doing things and many new structures for your program.

Quote: "my next question is that i was hoping you could give me an idea of a basic 2d game i could create using just the basics. nothing too fancy just something to help me learn a little bit more."

To be honest I think pong is a greate first game to make. It's easy and you can test out types with it. Although pong isn't that exciting I was pretty happy when I first programmed it.

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 1st Nov 2011 17:29 Edited at: 1st Nov 2011 17:33
Your code is not too bad from a neatness and readability stand-point (Mine was terrible for my teenage years. I slowly became neater and realised soon that neatness helps you think - I was amazed!). Anyway, I'll make some style suggestions and you can choose what to adopt and what not to.

This is just my personal taste. I don't stick hard and fast to it (especially not with the uppercase keywords thing). The indentations are the most important. Also, don't put so many empty rows in your code because it actually ends up looking quite messy. Only put blank rows where really necessary, otherwise use comments as separators (again, just my personal tastes).

As for your code structure, I can't really say anymore than's been said. You should look at the DBPro internal help on Data Types, Arrays, Etc. It's actually better written than the stuff I learned from in my early teen years. A good thing to remember is elegance through simplicity. Take your code and try to rewrite it in the simplest, neatest form you can. Good luck!

fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 1st Nov 2011 18:48
Quote: "You can also create arrays of types such as:
dim spaceships(10) as ship"


so would this would this work:

spaceships(1).x = 100
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 1st Nov 2011 21:15 Edited at: 1st Nov 2011 21:15
Yes, that would work. You can also tie types together into other types. One thing I like to use a lot is this:



Then you can do things like this:



TheComet

fllwthewolves
13
Years of Service
User Offline
Joined: 4th Sep 2011
Location:
Posted: 2nd Nov 2011 05:29
Quote: "
Then you can do things like this:
"


you just blew my mind. thanks thats very usefull to know.

Login to post a reply

Server time is: 2024-11-22 12:12:49
Your offset time is: 2024-11-22 12:12:49