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.

Geek Culture / Programming my own city-building game. Crazy attempt?

Author
Message
Yodaman Jer
User Banned
Posted: 10th Feb 2012 17:09 Edited at: 13th Feb 2012 15:13
Update, February 13th, 2012


I now have a logo and name for this project!




For the past couple of weeks now, I've been playing old city building games like Caesar 3, Pharaoh, Zeus, etc.,. I u sed to love playing those games when I was younger, and I've always wondered just how hard it would be to create a city-building game from scratch.

I'm thinking I'd like to program my own game, and I even have decided on an era. It's unusual because I'm going to stick to a lot of accurate details, meaning I've got a load of research to do.

I have an idea on how to approach it, too. Basically, Types will be my best friend for this whole thing. There will be a Type for buildings, and within that type could be variables called roadAccess, marketAccess, waterAccess, worshipAccess, houseLevel, basically things I can access and modify to make the house evolve in beauty, and check if it has access to markets, religious facilities, and most important, road access.

I'm thinking I'm going to be doing this in 3D, and (don't hate me) I'm going to use Blitz3D for the project and then later port it over to XNA for a potential Xbox game.

I just want to know a few things first. Does my approach sound like a fairly good idea? Creating types, checking certain variables against conditions like this...



Secondly, has anyone here developed their own city-building game? If so, can I have a few pointers please?

Eventually, I'll post another thread here detailing my exact progress on this, but that will be a WHILE from now, possibly a year or more. I want to make sure I've got all of the mechanics working before even attempting to release a demo. I literally expect this whole project, especially since it will be full 3D, to take me at least TWO YEARS.


Click to go to my blog!
bitJericho
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 10th Feb 2012 18:08 Edited at: 10th Feb 2012 18:48
Sounds neat. I'd definately go the object oriented route. I think blitz allows objects, so that'd be a good language to use. If you're deadset on basic, you might try purebasic, which isn't object oriented but allows really advanced stuff with types.

Don't rule out darkbasic either, while not as advanced as purebasic in terms of data and code flow, it's probably the most advanced 3d engine you can program in basic with.

if it were me and I wanted xna, I'd probably find an engine that will do XNA out of the box.

Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 10th Feb 2012 18:31
Even though it seems like a monumental task, I would say a city building game is probably one of the best genres to make, long term. Simply because, assuming you're going to emulate the grid-style gameplay of the games you've mentioned, most of the core can be pretty simply programmed by storing the map as one huge array (or something similar), so its very easy to keep your code organised. Where as FPSs or RPGs can pretty quickly spaghetti into oblivion.

It's sounds like you've got a very simple but effective method of organising the individual buildings as well, so kudos for that. Best of luck with this project, sounds pretty special. Which era were you gong for?

old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 10th Feb 2012 18:45
Im working on making a Sim city like game engine using VB but its still in planning stages. Best thing I can suggest is build your grid using an array aka code and then setup a click event based on the grid block you click. Each object will consume X amount of grid blocks. I hope that helps.
Yodaman Jer
User Banned
Posted: 11th Feb 2012 00:29 Edited at: 11th Feb 2012 00:32
@INH:

I'm going for the Renaissance-era, somewhence about the early 1500's all the way to exploration and creation of Jamestown here in the US. I want it to stick to some pretty historical stuff, although that does limit some things, like winning certain missions (i.e., in order to win a scenario in the game, you might have to lose the battle, etc). I did a quick Google search and the only game I could find that called itself a Renaissance city building game was "The Guild 2: Renaissance", but the artwork was more medieval/dark ages-y... sadly, there's a huge misconception and people seem to think the dark and medieval ages are PART of the Renaissance. Not quite.

There's lots more about the game ideas I have but I don't want to give away too many of them just yet. I'll wait until I have a basic program working.

@Jerico:

I haven't ruled out DarkBASIC, although the main reason I want to go with Blitz3D is that it has better support for Windows 7, whereas DBP is known to have several issues these days. Also, the graphics Blitz can do are slightly better somehow (not sure what the huge difference is between it and DBP, they both use DX9 I think). Another thing is I do NOT want to use ID numbers with DBP. I figure the best way to get around that is use a language (like Blitz) that uses handles instead of ID numbers, as it makes a lot more sense and is way more C like. I am, however, going to make a sample program with DBP just to test out a few basic ideas and then port it over to B3D when I purchase it.

Thanks for encouraging me guys, I can't wait to get this started!

EDIT: Oops, sorry old_School! Didn't mean to leave you out. How far are you on your project? Are you using XNA with VB or something else? Thanks for the tip about arrays, I'll keep that in mind.


Click to go to my blog!
Doomster
17
Years of Service
User Offline
Joined: 8th Nov 2007
Location: Germany
Posted: 11th Feb 2012 00:53 Edited at: 11th Feb 2012 00:57
Blitz3D is actually using DX7 (which is emulated under Win7 & Win8, which probably results in some performance loss) and is not updated any longer, as far as I remember.

So the graphical capabilities are basically worse than the ones of DBP (since DX7 is unable to make use of shader effects), as well as the compatibility, since it's using an even older DX which is more likely to become unsupported.

Yodaman Jer
User Banned
Posted: 11th Feb 2012 00:58
Hmm, yeah, didn't know that about Blitz. That's really unfortunate as it's really pretty powerful. There's hardly any plugin support as well, and honestly it looks like they're kind of dying. Maybe sticking with DBP would be the best idea for now.


Click to go to my blog!
Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 11th Feb 2012 01:53
Quote: "I'm going for the Renaissance-era, somewhence about the early 1500's all the way to exploration and creation of Jamestown here in the US."


I don't know much about the Renaissance, but I am a fan of very early American culture, so that sounds very exciting. I look forward to cannons, flintlocks and gratuitous flag waving

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 11th Feb 2012 19:10
I prefer the theme park versions like Roller-coaster Tycoon. Basically the same code, but with some different physics.

leo877
17
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 11th Feb 2012 23:12
@ Yodaman
Hi. I just read this and have ideas.

First Did you buy DBP before the bonanza pack or did you buy the bonanaza bundle.
Quote: "Another thing is I do NOT want to use ID numbers with DBP. I figure the best way to get around that is use a language (like Blitz) that uses handles instead of ID numbers, as it makes a lot more sense and is way more C like"
there a plug in for DBP called Extends (I think it does what you are sayin, theres more info on there page about it). I try it before it does replace the number thing. I just never got the hang off DBP yet.

Second XNA. sounds cool to export a game from DBP to XNA... I also have thought about this and did my own research of what to do. I notice that XNA use C coding and DARKdgk use C coding with DBP plugin. Converting from one gdk to xna just take some tweaking.this just my thought on how i would do something with my project.

Third Good luck on your project and hope to hear more from your game.


Grykon
19
Years of Service
User Offline
Joined: 30th Aug 2005
Location:
Posted: 11th Feb 2012 23:36
As someone who loves Knights and Merchants, Sim City I find your idea interesting. You might want to consider in your types having a building stage so when they start building you see a progress of the building going up. Certainly something I hope to follow your progress on!
Rampage
17
Years of Service
User Offline
Joined: 4th Feb 2008
Location: New Zealand
Posted: 12th Feb 2012 00:11
XNA uses C#. DarkGDK uses C++.
Unless you're talking about converting DarkGDK .net.

Regards,

Max
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 12th Feb 2012 00:14 Edited at: 12th Feb 2012 00:15
Yodadude, I dislike using numbers in DBP too, hence I use a work around. Just make a 'freeobject' function and store them in separate variables. I think there's a code snippet somewhere on the forums, but they're easy as pie to make - just find an unused object number and use it. Also, 'freeimage', 'freesound' and even 'freephysicsbody'.

So,
character = freeobject()
load object "bananaman.x", character

Or even store object variables as arrays - because with things like characters I use more than 1 object.

What I'm using at the moment is 2 objects for each character. The physics object and the object you display. Even then I don't need to type individual numbers. For example:



My array labels apply to other things, including inventory, for example:

item(Stamina, got) = 1
item(Stamina, effect) = 200

I think it's a much more convenient way of dealing with numbers without needing to remember what numbers you've actually used. I just remember what I use by their variable labels.

Of course, you'll be thinking in terms of a City Building sim, so what you go for will be different, but I hope anything I've said is useful.

leo877
17
Years of Service
User Offline
Joined: 6th Mar 2008
Location: san antonio, tx
Posted: 12th Feb 2012 00:32
@rampage
thanks for making it clearier.. like i said i did my own research and this is what i thought how it might work for me.
i also dont know what is DarkDGK .net is but thanks for the info


Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Feb 2012 02:55
Use ogre with C++, it is boss.

heyufool1
16
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 12th Feb 2012 03:16 Edited at: 12th Feb 2012 03:17
Quote: "Use ogre with C++, it is boss."

Definitely. It has a good community, you got the power of C++ to back it up, and you have the source available if you are daring Seriously though, C++ is stable, has an almost infinite amount of resources, and isn't as bad as people make it out to be. If you are already expecting a project to take 2 years then you don't want to use a product that is starting to disappear (Blitz3D). It's also nice to have commercial quality games backing the product and Ogre has Torchlight and Zombie Driver. Sure there is a lot of work involved and maybe it's just me, but I enjoy starting from scratch (C++ and Ogre) and then building the engine and then building the game.

"So hold your head up high and know. It's not the end of the road"

Burning Feet Man
17
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 12th Feb 2012 05:04
Quote: "I haven't ruled out DarkBASIC, although the main reason I want to go with Blitz3D is that it has better support for Windows 7, whereas DBP is known to have several issues these days."


I haven't had any show stopping issues programming & compiling DBpro games on Windows 7. Just update to the latest beta if you're having problems. Also note that TGC are working on a DBPRO update, although not too sure what the ETA is for this. If you know of any serious issues in DBpro, be sure to let TGC's know via posting in this thread;

http://forum.thegamecreators.com/?m=forum_view&t=193289&b=1

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 12th Feb 2012 10:46
I have thought about making a city management game for a long time. I've been a big fan of SimCity from the original up to 4, even (*gasp*) Sim City Societies. The Cities XL series is pretty good, and I love me some Anno 1401, Dawn of Discovery, and Anno 2070.

I think the hardest part would be to get all of the assets required to make it look good with plenty of variety. Gotta have several different single family houses, duplexes, etc. Several different office buildings(for tier 1, 2, 3(or whatever you plan out in development)), several trees, bushes, decorations, roads, city buildings(city hall, waterworks, etc,) streetlights, fire hydrants, people(?), cars, trucks, buses, airplanes, Godzillas... (?!), etc, etc.

I know they would be fairly low poly, but If you have several buildings (20-30-50+) on the screen at once, gotta have some variety and most should be different.

My green thumb grew the tree my Trojan War horse was crafted from. With roses in our pockets we rally round the tombstones. Ashes to ashes, we all fall down.
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Feb 2012 15:46 Edited at: 12th Feb 2012 16:01
Quote: "I think the hardest part would be to get all of the assets required to make it look good with plenty of variety."


I agree in a sense that this task could be hard for some, especially working solo. But I think it's more of a time issue, as opposed to difficulty.

To me the most difficult part... (and I only realized this,, when I attempted to work things out on paper) is the metrics, algorithms, analysis of the simulation AI. Coming up with a rule base for evaluating the layout... whilst keeping a good balance that is fair, allows for strategy, is fun while also being somewhat predictable. (Nothing is more frustrating than feeling the game is just being random with you,, that it's not truly evaluating the components of the city and the cohesiveness of the infrastructure)

This process of cost/benefit analysis was simple for the first few passes, such as evaluating the zoning and proximity of base layers,, energy connectivity... It got more complex (though doable) to evaluate the entire tree of effecting factors including roadway design, utilities, quality of life, generating interesting and varied events based on said data analysis etc... The list got huge fast, and I realized early on that an iterative analysis was not efficient... and I'm not always good at figuring out/or choosing the best recursive solutions.

And developing an efficient queuing or threading method to handle processes, so as to not stall the game-loop; all the while somewhat maintaining the illusion of 'real-time' analysis that is in sync with most current data. You can't have the game processing too long, like master level chess algorithms of years gone by. So prioritizing the processes, evaluating, triggering events, maintaining a sense of accuracy... while allowing for fluid game-play... etc... etc... was a difficult challenge,, at least for me.

~ZENassem
zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 12th Feb 2012 17:00
Quote: "I agree in a sense that this task could be hard for some, especially working solo. But I think it's more of a time issue, as opposed to difficulty."

You're right. I mistyped. I meant that the modeling and texturing would take a lot of man hours and it would be difficult to stay on track, not get burnt out, etc. while keeping to a certain style and standard.

Quote: "You can't have the game processing too long, like master level chess algorithms of years gone by. So prioritizing the processes, evaluating, triggering events, maintaining a sense of accuracy... while allowing for fluid game-play... etc... etc... was a difficult challenge,, at least for me."


I think the best way to do this would be to not update each sync. Only update certain things at certain times. Like electricity every couple seconds, quality of life every 4 seconds. Pollution every 10 seconds. Or possibly go through predetermined zones of the map. One per update. a 10x10 grid would have a hundred zones. Have 1 zone updated per sync (or every other). At 60 FPS it would only take ~1.6(~3.2) seconds to go through all of them. I've noticed in games like SimCity, certain things are not immediately updated. There have been several times where I drop a power plant, hoping that all the little lightning bolts would disappear, and after a few seconds start looking for a break in my power lines before the city was updated and the icons finally did disappear.

My green thumb grew the tree my Trojan War horse was crafted from. With roses in our pockets we rally round the tombstones. Ashes to ashes, we all fall down.
Yodaman Jer
User Banned
Posted: 12th Feb 2012 19:46 Edited at: 12th Feb 2012 22:03
Wow, thanks for all of the input and ideas everyone! I'll definitely look into using Ogre eventually, although my C++ knowledge is pretty slim. Who's to say this project can't be the start of learning, though?

I'm putting together a prototype in DBP right now. So far, for typs this is all I have...



I'm thinking each type of building will have its own Type object, as it will allow me to easily change a property of any kind of building. I'm using arrays with no numbers in them and will use "insert array at bottom" when the player creates a new building. Otherwise, if I don't the player has a chance of reaching the limit, even if I dim an array that's over 9000.

What do you think? Good so far?

Oh, and about finding free object numbers, I'm using a different approach that someone taught me ages ago on the forums. You create a variable that you use to assign id's to objects and then check in a while loop if there's a free number....



It's really that simple. This loops through the variable and if it finds an object number, it increases until it finds a free one. Super easy to implement and use! It works very well for level editors, which really, is sort of what a city-building game could be equated to in terms of programming.


Click to go to my blog!
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 12th Feb 2012 23:07 Edited at: 12th Feb 2012 23:07
I would guess that your "find free object" code above is rather slow if you have a ton of objects to parse through. Is there any way to make a dynamically-sized array in DBP? I've forgotten. But parsing an array is probably faster than parsing objects.


Senior Developer - CBS Interactive Music Group
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Feb 2012 23:19
Or you can use the command from Matrix1 Utils:



TheComet

Yodaman Jer
User Banned
Posted: 13th Feb 2012 00:09 Edited at: 13th Feb 2012 03:16
Oh dear Comet. I totally forgot about Matrix 1's find free object command. I think I'll adjust that now.

EDIT: Jeku, that would certainly explain why there was a delay in my old level editor whenever I started creating objects with id's greater than 20 or so. I thought maybe it was just because it was too messy, but maybe that was the cause. Hopefully, the find free object command works more efficiently!

Also, quick question. This was an issue I had a while ago as well.

Say I loop through objects to check certain things, like if they have access to a road or not. I would use a for-next loop to check the array's elements like so....



This works great, but there's a problem...

Because I'm allowing the user to clear buildings and stuff, that means an object gets deleted. I had a problem with one of my old editors in which whenever I deleted an object and changed the variable holding the total amount of objects on screen, the totalObjects variable wouldn't work anymore. Is there a way I can shift all of the indices of the array DOWN so that I don't have to have a "totalHouses" variable?

For example, here's my house creation code.



That assigns the id number to an array index. Is this bad practice or a good idea? I have no idea.


EDIT: Well I found out I was doing something entirely the wrong way.

In order for the newly created "house" object to be assigned to the array index, I need to have the function work like so:




This works MUCH better! I used the array count command to make sure everything was getting assigned properly and it is! Yay! Previously I was getting strange results. Every time I created a house, the array indices would get all weird and for every one object I created, the array would double by about 2.5%! It didn't make any sense but I think it was from using the array insert at bottom command incorrectly. It works now!

This is not going to be as difficult as I thought!


Click to go to my blog!
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 13th Feb 2012 16:28 Edited at: 13th Feb 2012 16:51
@yodaman jer,, The problems you are running into is exactly the difficulty in the analysis that I was referring to,, in keeping in sync with current data,, but not stalling the loop, efficient queuing system etc... I never really developed a complete solution. I did however come to certain conclusions

- Rather than using an array,, linked lists provided a better data structure. Setting up an effective queuing system that could prioritize what data needed to be analyzed first is a must.

- Couldn't use a for loop to analyze the data structure... It worked out when the infrastructure was relatively small, but as things grew in complexity the amount of time spent in the loop stalled the game loop. As mentioned above,, I had to give up on analyzing data in real-time,, given that items can be manipulated as you are processing their old existence. So i would have to keep manual track of my index into the structure, and continue processing it either based on time, or main-loop count. I found that it was acceptable,, and that I had to live with a delay at times... Same thing happens in Sim City. The important thing is to handle what the user is doing as a priority, and update that,, the analysis of said changes will be behind but eventually catch up.

- Take a look at union-find algorithms with trees including Weighted Quick Union with Path Compression by halving. Source: Algorithms in C Parts 1-4: Fundamentals, Data Structures, Sorting, Searching ~Robert Sedgewick

~ZENassem
Yodaman Jer
User Banned
Posted: 13th Feb 2012 22:23 Edited at: 14th Feb 2012 00:32
Hmm... I'm totally unfamiliar with lists and queues, although I know Blitz uses some of form of listing... Could you perhaps provide some sort of example, zenassem? I just don't quite follow.

EDIT: Oops, it appears I'm already using lists...?

What I'm doing in my code is creating a Type for each building. Houses, markets, warehouses, water fountains, etc.,. Then I'm creating an array with no elements for each type like so (so far I'm just testing with a basic house)...

dim house() as House

Then when I'm creating a new house object, I put it in the array like so:



Is that at all like what you're talking about? I have no idea how to use the add to queue() command yet. Perhaps I should look into those before moving ahead much further.


Click to go to my blog!
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 14th Feb 2012 00:38
I'll do my best,, it will take me a little time to edit everything in.

First off DBpro has what are described as Lists. I think the name "Lists" is a bit confusing/misleading... It's more of a dynamic array,, but still it's better than using basic arrays (where you have a predetermined size and manipulation code to prevent gaps caused by deleted elements.

I'll explain actual linked lists and use of pointers below.

Quote: "

LISTS

Similar to an array, a list can expand and shrink based on the number of items contained. A list can theoretically have no items of data contained within. In contrast, it can store as much data as your memory availability allows. Accessing data through lists allows faster access than arrays in that there is no need to skip redundant items within the data. Items added and removed from a list are done so efficiently, removing the need for large clunky array sorting. You can also traverse a list without the need to know its size.

The list commands are:
EMPTY ARRAY
ARRAY INDEX TO BOTTOM
ARRAY INDEX TO TOP
ARRAY INSERT AT BOTTOM
ARRAY INSERT AT TOP
ARRAY INSERT AT ELEMENT
ARRAY DELETE ELEMENT
NEXT ARRAY INDEX
PREVIOUS ARRAY INDEX
ARRAY COUNT()
ARRAY INDEX VALID()
"


DBpro also has queues... and they are fairly straight foward. The part that I may need to work up some example code on,, is having a handler direct and prioritize data into the right queue. With regard to your type of application,, I think you will want to set up a few queues with different priority level; meaning that certain queues will process data on a greater interval than other less important queues.

Quote: "

QUEUES

A queue is summed up by the term "first on, first off". Queues collect data added to it in a linear sequence of items, and the data is removed in the order in which the items where added. Queues are good for buffering data for later processing, where the order sequence of data is important.

The queue commands are:
ARRAY INDEX TO QUEUE
ADD TO QUEUE
REMOVE FROM QUEUE

It is important to note that multidimensional arrays cannot be accessed by stack and queue commands. Use single dimension arrays for these type of commands.

"


Need to edit in....

Linked Lists
BST's
Connectivity problem & Algorithmic solutions (Union Find)
Queue Priority Examples

~ZENassem
Yodaman Jer
User Banned
Posted: 14th Feb 2012 00:46 Edited at: 14th Feb 2012 00:48
Thanks zenassem! I look forward to some pseudo code for queues as DBP's description of them is still rather unclear to me, though I think I see why I should definitely utilize them!

I think I may already be using lists though, I added it into my last post. It looks right to me, anyway.

EDIT: Aha! And to simulate C's "foreach" command in DBP, I simply have to do....



That way, I don't have to keep track of the total objects made for loops, and object numbers are completely averted!


Click to go to my blog!
Yodaman Jer
User Banned
Posted: 15th Feb 2012 15:43
Sigh...

I think I should definitely attempt this project in XNA. I've looked at several examples of lists and arrays in C# and it all just makes a lot more sense than DarkBASIC's commands. Plus, if I do this project in XNA now, it gives me the definite option of porting the game over to Xbox later without having to change too much code.

I just ordered this book which should help get me started. I've got another book on XNA as well but it doesn't go into too many details about the code, it's just example after example with NO comments.


Click to go to my blog!
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 17th Feb 2012 19:47 Edited at: 17th Feb 2012 19:48
MSDN is a good place as well to get support for learning XNA. Hope that helps
zenassem
22
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 18th Feb 2012 03:00
@Yodaman Jer,,
I've been a bit lazy this week with regard to programming. As of right now the it seems the closest/easiest way to emulate linked lists in DBpro would be through the use of Ian M's Matrix1Utils plugin.

Specifically the addition of pointers to indexes of arrays. The commands are listed in the Matrix1Utils help under Matrix1Util_29. Hopefully I can stop my obsession with 'Words With Friends' and 'Spades' this weekend, at least long enough to do some basic implementations.

Applying that concept to a Binary Search Tree,, and implementing an example of solving a connectivity problem shouldn't be much of a leap. Implementing the queue handler along with a basic example shouldn't take more than an hour. So hopefully I will have a status update by Sunday morning.

If Ian M see's this,, I would bet he has already worked out a linked list implementation utilizing Matrix1Utils... So I'm quite sure that my fumblings will be trumped.

Best Regards

.oO()Oo.oO (I'm not a real programmer,, I just play one on the Forums!!!) Oo.oO()Oo.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Feb 2012 04:33 Edited at: 18th Feb 2012 04:40
Quote: "I would guess that your "find free object" code above is rather slow if you have a ton of objects to parse through. Is there any way to make a dynamically-sized array in DBP? I've forgotten. But parsing an array is probably faster than parsing objects."

I know it's not very tidy but couldn't you just increment a variable each time you add a new object and not bother about when an object is deleted? Or is there going to be a high turnover of objects?

@Jer
I don't like the name, wouldn't just "Renaissance" be better? It is an era in itself isn't it? So calling it "Eras of the Renaissance" look wrong and clumsy.
I like this period and I can't recall a city-sim game set in that time. Would you like some help? I can't guarantee support for the whole development but even helping with the odd bit of code or researching scenarios would be fun. Look up the Borgias, you could do a whole campaign based on them.

Join DNG today! We are a game development team open to all. Visit our Headquarters to learn more.
Yodaman Jer
User Banned
Posted: 19th Feb 2012 00:28 Edited at: 19th Feb 2012 00:28
Quote: "I know it's not very tidy but couldn't you just increment a variable each time you add a new object and not bother about when an object is deleted?"


Not if you use for-next loops relying on the variable that holds how many objects there are. If you're trying to do something with an object and it has an ID of 4 let's say, and it loops through and doesn't find object 4 it'll crash. This is why lists would be a lot better because it doesn't exactly rely on exact index numbers. At least that's what it looks like...

And yeah, I'm gonna change the name of the game too, although there was more than one Renaissance... So technically my name could work just fine depending on what exactly I go for.


Click to go to my blog!
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Feb 2012 04:46 Edited at: 19th Feb 2012 04:48
Depending on what sort of performance you're expecting and how many objects you'll have on the screen, you might want to 'merge' objects into one before rendering them for a performance boost, reduces the number of batches you need. Obviously this complicates things, but it can work well. In darkbasic/darkgdk you have the vertexdata commands, or you can probably use the index/vertex buffers directly in XNA.

Yodaman Jer
User Banned
Posted: 19th Feb 2012 15:42
@Indicium:

This is another reason why sticking with DBP would be good; Dark Occlusion. Using that could REALLY speed up the performance of the game, especially for a planned camera angle that lets the player walk through the city.

Add honestly, I have no idea how I would merge things with vertex data commands. Is it really that terribly inefficient to have the program render every object as its own?


Click to go to my blog!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Feb 2012 15:49
Quote: "...there was more than one Renaissance, so technically my name could work just fine..."

Sorry I forgot about the first Renaissance, still I think it is wise to have a shorter name.

Quote: "Not if you use for-next loops relying on the variable that holds how many objects there are... This is why lists would be a lot better because it doesn't exactly rely on exact index numbers..."

So you're going to make a separate array that indexes the model numbers in use?
e.g. list[0] = 5, would make object 5 the first in the list to be acted on. If object five was delete the list would be changed, e.g. list[0] = 2.
That is a good idea if I understood you correctly. It would mean you don't have to check for objects existence every loop.

Join DNG today! We are a game development team open to all. Visit our Headquarters to learn more.
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Feb 2012 17:01
Quote: "Is it really that terribly inefficient to have the program render every object as its own?"


It really depends, when I was working on a little minecraft clone, I would test with little over 1000 cubes, and I'd get unplayable performance (I have upgraded my graphics card since, but that was on a 8600GT). When I merged the cubes using vertexdata I would get over 200fps.

I might be wrong on a few details, but it's because objects are sent to the graphics card in batches. Each object makes a new batch, and graphics cards don't like batches, so the fewer you send, the better performance you get.

How many objects do you expect to have on screen at one time?

Yodaman Jer
User Banned
Posted: 19th Feb 2012 19:46
Wow, I have no idea on this whole batching thing. I think I need to research it a lot more.

As for how many objects I expect on screen, probably at the most a section of the city would contain no more than 50 buildings depending on how far in the user is zoomed (which also affects how well Dark Occlusion would work). Can you give me more information on merging objects please? That sounds like a really useful thing to learn right now.


Click to go to my blog!
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Feb 2012 20:46
Quote: "Wow, I have no idea on this whole batching thing. I think I need to research it a lot more."


I wouldn't worry to much about it, I probably have the most basic grasp on it as is possible.

If the maximum number of objects on the screen will only be about 50, you don't really have much to worry about, I thought you might be able to see entire sections of the city at once and have hundreds of objects on screen.

It would probably be quite complex depending how on how high poly your buildings are, if they're just simple textured cubes then there is no problem, but if they're complex then quite a lot of effort will have to go into it. It's definitely worth it for the performance increase IMO. It's probably best to make an informed choice on the matter, so here's my list of pros and cons for the method.

Pros:

->Renders much faster
->Depending on what collision system you choose to use, if any, it can all be detected on a single object.

Cons:

->More complex to code
->Longer initialization time (It's a tradeoff between more initialization time, constructing your objects, or the objects taking longer to render )
->You have to use a single texture map, you can only have one texture on an object, so you have to set each buildings textures using UV coordinates of a single texture.
->Harder to select individual objects using pick object commands.

It seems a lot, but if it's performance you want, it's one of the best ways as far as I'm aware. The way you would pull it off varies from engine to engine. In darkbasic you use the vertexdata commands, in Ogre you can use the ManualObject or SimpleRenderable classes, and I'm sure there's a way in XNA.

Hope this helped. xD

Yodaman Jer
User Banned
Posted: 20th Feb 2012 05:37 Edited at: 20th Feb 2012 05:42
Dang! I just learned some more about lists in C# and holy cow, it's incredibly simple and useful!

All I have to do is use code like this...



It's SOOO much easier than DBP's clunky nature with arrays and super long commands like "array insert at bottom". Why couldn't they make it as simple as C#?!

Definitely going the XNA route with this now.

EDIT:

Also, I think you're right Indicium, XNA has the "spriteBatch" class and so it would stand to reason they might have a 3D batch class somewhere as well... definitely have to look into this more because it's super easy to draw multiple things in a batch with 2D sprites in XNA. Literally, it's as simple as this...



Sop hopefully it's just as simple for 3D stuff. If it is, I'm going to get so excited I'll barely be able to keep my excitement!


Click to go to my blog!
old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 20th Feb 2012 06:42
Lol allways a simple solution out there. I would still consider using an array though because you will need to handle each box when its clicked etc.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Feb 2012 13:00 Edited at: 20th Feb 2012 13:04
Quote: "It's SOOO much easier than DBP's clunky nature with arrays and super long commands like "array insert at bottom". Why couldn't they make it as simple as C#?! "


It doesn't look better to me. I'm sure that A$(n) is almost identical to that, but the n helps me to know where I am.

zeroSlave
15
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 20th Feb 2012 13:29 Edited at: 20th Feb 2012 13:57
Mmmm... Arraylists.....



This is a snippet from an Android game I am working on.
The great thing about lists, is you can put pretty much anything anything into them. This would be great for storing individual buildings, their x,y,z positions, electricity usage, dwelling population, or anything else you have inside of the Building Object.

There is internal sorting methods so you don't have to fool around with Bubble Sorting arrays and such.



There are tons of other benefits, but I thought I'd just show an example.

You can even go all crazy and do something like this:


I upload the App that I use this in on the Android Marketplace. If you wanna see it in action, search for 'Coughmist' and then it should be listed as 'Rebuke Star ConquestTest' It might not be up for a bit, I just uploaded it.

Yodaman Jer
User Banned
Posted: 21st Feb 2012 00:51
Great examples there! You've preemptively answered one of my questions about combining classes and lists. I now know how.

It's amazing how alike C# and Java are.

Anyway, I think I'll stick with DBP for this project. I just need to figure out how to use arrays as lists (already have, I think), and the main reason I still want to use DBP is because of the great Dark Occlusion plug-in, Sparky's, Cloggy's D3D and BlueGUI. It's amazing how well all of those things can work together, and plus, DBP is a language I know pretty well now.

Now to some more sad news...

I'm putting this project on hold, but not forever. Just until I better understand using lists, the Matrix1 commands, and other very useful and time-saving functions. The only way to go about this, though, is to actually program something else first!

I'm thinking a grid-based 3D editor for another game idea I have, which would be pretty similar to a city-building game, just without all of the AI simulation. So, that's what I'm going to do. Build a 3D grid-based editor whilst coming up with the finer details of this game idea.


Click to go to my blog!
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 21st Feb 2012 01:51 Edited at: 21st Feb 2012 01:57
Yodaman Jer,

I've just had a quick peek through your thread, and I think you might be interested in this tutorial I wrote back in '07 about handles to objects and all kinds of other data.

http://forum.thegamecreators.com/?m=forum_view&t=115298&b=1



[edit]

I'd like to note that I have thought of a better technique for a FreeObject() function since that tutorial. If you're interested here it is.

You have one global integer that starts at 0, and one global array, that starts off empty. When you want a new object, increment the counter, and return the number, unless the array has elements in it. If it does, pop the last element off and return it. When you delete an object, simply add it's number to the array. That's a real easy way to allocate objects in constant time.

"everyone forgets a semi-colon sometimes." - Phaelax
Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 21st Feb 2012 02:21 Edited at: 22nd Feb 2012 01:29
What exactly are you trying to do with your lists? I've just been using them for my inventory system. I don't know if this will be relevant to what you're doing with them, but I can do my best to help if they are.

This is aimed at an inventory, but I suspect it's possible for you to adapt it for how you want to use your lists.

In addition for explanations of Grids and lists, this XNA tutorial from 3D Buzz goes into a certain amount of depth (though no code is shared in that tut) and in a way that's understandable for even a complete newbie - I think they cover it fairly early on in the tut too. Linky

Anyway, first off, the UDT.


The inventory itself is defined by a number of 'slots', those slots are actually the list.

Lets say:
dim Item(20) as Inventory

That's an inventory of 19 slots. I use 20 because 1 slot will be a dummy, so when it comes to the code where I'm selecting an empty slot, slot '20' won't cause for the last slot to be selected or an error saying, "Array doesn't exist" when the 'next x' starts at 20. There's other ways of dealing with it (and you'll see what I mean when you get to it), however, that's how I've done it.

Then I have an Update function (to be used in your loop) to check what 'item' is currently in each slot.

For example:


So all the code needs to do is check the names of each slot and then apply stats to them. I also use 'effect' to decide what they actually do. 'Health' and 'MP' items can be used in the item menu, whilst 'Sword' and 'gun' can be equipped.

To add a new item to the list, obviously, you adjust it to your needs, mine has the player and scene item collide and the play hit enter to add it to the list. In fact, the scene itself has its own list, its list contains any items in the scene, so the code has to tell it to remove that item and add it to the player's list, hence the variable 'scene' is needed. I've not posted any scene code, so if you need explanations, I can provide.




I also add a 'default items' function too, which looks like this:



Because of the 'Update' function earlier, you only really need to use the item's name and quantity to add it - the stats will follow or for the case of weapons, you may wish to tell the code it's equipped.

So as you add new items to your list they will stack. The only trouble is, if you remove an item that's not at the bottom, you've got an unused slot at the top. For this I wrote a 'stack' function:



Basically it checks if there's an empty slot, gets the item from that slot, adds it then clears that slot. All I'm left with to figure out is how to 'sort' my lists...if I work something out I could keep you posted, but so far, I've not even thought about it, but I suspect I'd need to write a parser for it.

Also, here's something that should demonstrate the functionality for the items on the list:

In a x = 0 to total for/next loop (which is, total number of slots filled)


To break it down, if it reads that 'Health' is the 'effect' or should I say 'restore health' then you'll increase the player's health by what is defined by the modifier, in this case (if you look at the UpdateInv()), you're see it'll increase by 100. This way you can create multiple items with the same function, but differ in effectiveness.

To work out the total number of 'filled' slots you can do this:


Then use that total to make a 'for x = 1 to total' loop and display all of names of the variables inside of your list:

Text 50, 60+h, Item(x).name : inc h, 30

Before the 'for x= 1 to total' loop include 'h = 0'.



If that sounds like what you want, I'm happy to go into more depth if there's anything that needs explaining.

You've got my email, you've got me on Skype and Facebook so there's more ways than one for me to chat.

If it's not what you're looking for, then best of luck and hope you find the solution you need.

[Edit]
It occurs to me that there's a number of typos in my comments...I don't proofread them.

[edit2] Demonstration of the above functionality (just with equipment added):
http://www.youtube.com/watch?v=m0Bx8AQ1P7U


Yodaman Jer
User Banned
Posted: 23rd Feb 2012 18:00
That is some really useful information there, Sepp!

RPG's don't look as complicated to code as I thought...

Even though it's unrelated, I have 3D grid snapping working!

http://coffeecodergames.weebly.com/progress-blog.html

Sepp, you and I use the same theme for our site. How'd you get menus, though...?

So yes, even though that links to a post about building a level editor, it's also one step closer to creating my own city building game. I knew building a level editor first would help me figure it all out.

Seppuku Arts
Moderator
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location: Cambridgeshire, England
Posted: 23rd Feb 2012 19:13
I usually try to find the least complicated way of achieving things. I think with an RPG the trouble is that you can end up with a lot of data and is possible to find ways of keeping on top of everything. UDT's do that extremely well.

To achieve menus on Weebly, you just need drag your pages so they look indented on the 'Manage Pages' section of weebly:



That site is a little out-dated as I moved everything over to Wordpress, I should really update that.


Quote: "Even though it's unrelated, I have 3D grid snapping working!"

Shaweet! Well that's good news indeed.


old_School
15
Years of Service
User Offline
Joined: 29th Aug 2009
Location:
Posted: 24th Feb 2012 17:53
Not trying to swing you one way or the other Yoda but c# is an industry standard gaming lang vs. DB that is community based language. So you’re trying to learn something new, so you have options.

You know DB a little I will assume. On the flipside C# is extremely easy to learn as well. DB has a nice small community for support. Flipside C# has the MSDN with millions of professional developers far more advanced. Flipside to that you get personal attention here but may not always be as helpful as the MSDN or direct you in the best direction code wise.

This also implies other questions you need to answer for your self:
How much support will I need to complete this project? Can I complete this with DB or do I need to use C#? Can I learn a new language if I had to or do I need to stick with DB? Will I need help on this project? If I need help, who can I trust and who will even be able to help me?

Basic questions of course. I don't know the answers but you do. Review your options of course. I recommend C# personally because it is the better language for this project in my opinion. If you notice as well their is not a lot of "city building" based games around here as well. Not saying it could not be done but I’m sure some have tried already and likely found or ran into problems/brick walls/limitations. However, you can run into problems using C# as well. It all comes down to your ability to learn and understand the language you’re using. If C# is easier for you use it. If DB is easier then use it.
Yodaman Jer
User Banned
Posted: 24th Feb 2012 22:40
Right now I'm going to program this in DBP once I finish my little level editor for a future game I want to make (I might end up making two games at once...), and it's actually helping me realize a lot of ways to make the city-building game in DBP. Object placement with grid snapping was my biggest concern at first, but now that that's all sorted out I have to work out how to use arrays as lists (this part would be way easier in C#, as I mentioned earlier).

Now that I've been studying C# so much though, I'm realizing how truly DBP is limited in several respects. C# is so much more flexible, and it's easy to learn/use the features it offers. I do plan on remaking my city building game in C#+XNA for the Xbox someday, and maybe (just maybe) a little WP7 companion app.

Login to post a reply

Server time is: 2025-05-22 09:36:46
Your offset time is: 2025-05-22 09:36:46