Saturday, March 30, 2013

New Developer to Assist...

Another developer has expressed interest in assisting with the game.  Similar to me he has considerable experience with .NET, and relatively new to Unity.  In order to get ready for multiple developers, I've added the project and design work to Team Foundation Server.  I also spent a little time organizing and cleaning it up.
Team Foundation Server is an excellent tool I've used before, and Microsoft has it for free now at tfs.visualstudio.com.  At least for a limited time.  By the time they go to charge (for teams over to 5) I plan to migrate the live version to my own TFS server (which I will have to setup)

Since the cleanup and TFS Sync are done, I'll be back improving the game.  I've got a few key areas to work on.  1) Map needs the tiles to expand, so when moving the view, the tile map appears never ending.  2) HUD should start getting a look/design work.  3)  Tiles need to smoothly fade from one tile to the next.  4) A speed bug with the map based on position needs to be addressed.

Friday, March 29, 2013

New Domain and game rotations

I have just completed the blog transition to Http://Blog.WarpWars.Net.  Also, WarpWars.Net is now the site with the demo.  (under very slow construction)

Unless something considerable changes, I plan to keep the name Warp Wars, with the sub names City, Tactics and Strategy.  Its grown on me.

Additionally, I have another game update, which is not part of the live alpha demo yet.  Rotation.


The video demonstrates the new movement and rotation abilities.  By clicking anywhere and dragging the mouse, the map moves to follow.  Instead of exact mouse mimicry, I applied a simple Velocity/Friction physics operation to the map.  This allows smooth motion, and the ability to 'fling' the map and move faster/farther in a single motion.

Of course I also added rotation, which is accomplished by pressing R while moving the mouse.  This hot key may change, but for now it works.  The rotation does not operate on the physics operations, so it follows the mouse more accurately.  

WASD keys no longer affect your map location. 

Again, the rotation and mouse based movement is not in the live demo.  I have a few things to try working out before I post another.

Thursday, March 28, 2013

Name Change Pending...

I just acquired WarpWars.net, which already resolves to the game site.  In the next couple days, blog.warpwarscity.com will not resolve.  Instead the new blog will be Blog.WarpWars.Net.

WASD - Client Version 0.0.4.344

New Demo Live - New Web Site Live - Go visit http://WarpWars.net/.

New Demo Live:

So the new demo is available.  (its url has changed, I think, so use the link above, and then click to see the live demo)

Here is what's up with this edition:
  1. All accounts still exist.  This did not require server changes.
  2. Each player now has a map.
    1. Anytime a player logs in, the map will look exactly the same.
    2. The map is different for each player. - I'll explain in a moment.
    3. Maps are not stored anywhere - I'll explain this too.
    4. Maps are presently 32x32 tiles, but the engine is capable of near infinite - I'll explain this to.
  3. The mouse move is now gone.
  4. You can now move around the game by clicking W, A, S or D, to act as arrow keys.
  5. Ambient Lighting now exists, so you can see a bit more

Technical Mumbo Jumbo:

System.Random in .Net is slow.  Doesn't seem like it, but to produce 1 million distinctly seeded height positions, it took > 3900 milliseconds every time.  So I discussed this with numerous other developers, on several forums, until I found a solution which required little effort.  The new randomization for 1 million distinctly seeded height positions is now < 67 milliseconds, 1.7% of the original time it took.  If anyone sees some weird randomization, let met see a screen shot and know which account name you used.

To keep a map of 1 million tiles (1024x1024 map size) It would have been nearly 50 megs of data.  With any luck, this city builder will have 10,000 players or more.  for those 10k players, we would have been using 500 gigs of storage on the server, plus the transfer of the data, and the management of it would have been a nightmare on performance.  (these maps change)  So instead, I use the randomization I mentioned above, to choose the height for each vertice (corners of the tiles) and the tile type.  
 - The randomized values come from one seed per request.  The seed is generated from the X coordinate, the Y coordinate and the player's Id.  This way everyone's map is different.
 - Since these are generated incredibly fast now.  I can entirely depend on it for live data.  
 - This is why there is nothing saved.  (also no DB changes)  The playerid, X and Y are already there.  The only thing that will transfer is the data about any terrain that has changed.  
 - Since the player's unique ID is part of the seed for each tile, the layout is different for each player.
 - Since the ID's, and Locations are managed with 32 bit integers, that means that these maps can go out more than 2 billion tiles in any direction.  (hence my near infinite)
 - I don't have it reprocessing anything with position yet, so you only see the 32x32 tile portion in the game now.

To Do List:

I need to start reducing the content size.  
 - The skybox I used on the game side is not needed.  
 - I'm presently using 512x512 pixel tiles that are throw away.  I should be using 64x64.
 - The Satelite is not ultimately going to be used.  It is a very high definition model, which is expensive on the initial packets download size.  
I also need to get the map to move with the player.  I.e. process the next parts of what they will see, and only provide a small portion of that to the rendering system.

New Site:

So the new site is up.  Before, you always had to go to /index.html, and if you didn't include that, you wouldn't get anywhere.  Now, there are two separate websites.  MVC4 Service based site, and an MVC4 Web Based Site.  I've only done a minute level of RAZOR modifications to the index, which you can see from the pic above.  It still looks like an initial sample page.  But this will get cleaned up over time.

Again, please note that the website is NOT a priority.  The game is.  I will get back to the website when the game is better off.  pieces here and there.  But I have no specific plans yet.

Tuesday, March 26, 2013

Maps are prettier, still need work though.

(No new demo online yet)
I've been working on the map system some more.  I went back to a random map, relying on code that I knew worked, but was at the wrong angle/position.  After messing around with that for a bit, I finally got the ground showing up at on the X/Z plane, with +Y=Up.  I built the code that produced all the vertices and UV mapping (textures) for every triangle of the ground (ideally every square) from scratch.  And with this, had to realign/position everything.  

I don't know why it seemed reasonable to me to use X/Y as the ground plane originally.  if I went with that, I'd have to rotate every object that entered the game, and external scripts wouldn't work in many cases.  The rotating camera motion is from an asset called Mouse Orbit.  it keeps a certain distance, from the target object, but its only lockable angle is from the Y Axis.  (so you can prevent it from looking on the other side of the models)  I would have had to rewrite the code for that as well.  I think I've been in the 2D X/Y side for too long lately.  So anyway, here is a screen shot from the new code.


Oh yeah, I also added a sky box.  Its a bit more fitting now with actual sky, instead of that faded dark blue.  The opening login is still the same space scene.  (Oh look, it spins.)



Monday, March 25, 2013

Dynamic Maps Update...

So I've been working on Maps in the game.  I believe my routine for dynamically producing map blocks (sections of map, 32x32) is near complete.  However, I have something wrong with how that routine gets translated back that I need to resolve.
This image shows the current bug with the tile map.  1, it is a jagged array of horror.  2, it shows up at the back instead of the bottom (where ground aught to be).

I'm hoping its just the display portion that is messed up, because the display code was working before, but perhaps there is something with the math on that that isn't working with the dynamics now.  I'm off to work, but hopefully I'll be able to get this resolved and operating shortly.

Thursday, March 21, 2013

Changing the mapping plan... Again

So, I've been basing the map on the idea that the server produces and manages the terrain, and then sends updates to the client.  However, someone gave me a great alternative and I'm going to use it.  (Yes, this means more reprogramming in this area.

Requirements:

  • Maps are unique for each player
  • The client and the server are aware of the same map data
  • Must keep bandwidth usage low.
  • The terrain can and will change both in height and in texture.
In my system, a 1000x1000 grid is still around 52 megs uncompressed.  Or 5 megs compressed, but requires heavier processing to load into memory/save again.

The new system will instead use a seed number, like Minecraft's mapping system.  Both the client and server have the same starting seed.  To begin with, I'll just use the players Id as the random seed, since it will be unique to each player, and that is already a critical piece of knowledge for nearly all other communications in the game.

The next issue, is making sure the map generating methods are fast and lightweight.  On the client, it will be passed onto a work thread.  But the server doesn't have that luxury.  The server will not hold data in memory, but at points it needs to process it, it will generate this data on the fly.  Fortunately, the server won't need to know it often.  Also, I'll split the Height Map processing and the terrain type processing, as those won't be needed at the same time in most cases.

The only detail needed on top of that, will be alterations, either from players placing things like roads, which changes the terrain textures, or placing buildings, which will level out the height map for a particular area.  These alterations are the only data that needs to be transferred then, and that is small enough/varied enough it will value from sitting in the database.

So, again, this is taking more time, but I've never built a City Builder before, or more particularly an RTS, that the game trio will be.  I've been wanting to, but held off until now, with Unity.

Texture systems will also change, but I'll save that for another blog, once I get to it.

Wednesday, March 20, 2013

Map Data downloading

Its been a while since I last posted (5 days to be exact) and I didn't want you to think that I've done nothing. Why I've spent a great deal of time thinking about nonsense, like Alderon and the 7 Dwarves (they both had buns on their heads)

But in a not to distant actual reality, I found myself dealing with an annoying bug in the latest update of Unity (4.1) where all my JS files now complain that they don't have a UnityEditor using statement.   But I just go that fixed.  I also spent a while thinking about the best formats to save the data to, came up with a really good one, but then went with the easier one for now.

I also established build environment configurations for the client and service.  This allows me to build for the different environments faster, as I don't have to change a whole bunch of settings for each environment.  This is important as the number of changing features have increased.

So now, at user generation, it creates a map file, stores it on the web site, and the client downloads it.  Then, it shows how large the map segment was in bytes:
Since this single number position value is the only thing that changes, and its only in this image (not uploaded), you might be thinking that all I really did over the last 5 days was accidentally break the resource dynamics so that only the Credits would work.  You'll just have to take my word that something cooler is happening behind the scenes.  :)

Friday, March 15, 2013

Considerations on Terrain Maps

So I'm still working on Terrain, and have no visual updates to include this time.  I started development on one form of terrain, but my original design was going to yield 50 megs map files that would need to be reloaded, edited and resaved by the server any time a change happens.  ouch.  I needed a better way.

First, I took a look at what my current architecture requires:

  1. Players have 3D maps, that can dynamically change and often during game play
    1. In order to place buildings, sections of land would need to be leveled. 
  2. The server is primarily responsible for logic, to reduce client hacking abilities.
    1. This even includes subtle validations on the land.
  3. MVC4 Restful Services would mean the data file for the map would need to be reloaded on the server every time a change occurs, or even just to validate land structures.  
    1. For the 50 Meg file size, and potentially hundreds of simultaneous users, this would have crushed the server from Hello.
  4. The MVC servers translates everything to text for transfer to client.  That would increase the content size, processing effort, and transfer speed of the binary map data.
To try to meet all of these concerns:
  1. The tiles will be managed in smaller segments, probably 32x32 tiles at a time, or 1024 tiles. 
  2. These blocks of tile data will be saved in binary form.
  3. The block files will be stored in a location accessible through the web.
  4. The client will directly download the smaller binary files, skipping the use of MVC4.
  5. Map Processors on the server side will be designed to work directly against the binary format, instead of fully loading the tiles into objects, allowing direct read/writes to the binary files as needed.
  6. Depending on the amount of data changing from the Server Side Map Processors, 
    1. Smaller data changes will be sent to the client to apply to memory directly and leave the cached map files alone.  When the client logs out and back in, it will download any maps files that are out of date.
    2. Larger changes will just download the map change immediately, and reload it into memory, overwriting the previous knowledge.
First proof will simply be the first 32x32 grid of tiles.  creating on the server, and displaying on the client.  No caching or anything like that yet.

I'm hoping this first draft should be ready within a week.

Also, some people have commented to me that they haven't been able to connect to the game client because there routers complain about the DNS.  WarpWars.RR.NU (or anything from .RR.NU) has its DNS set dynamically, which some security systems flag as dangerous because it is less stable, and has more potential of hiding hoodlums (Not Hoodlums!) with fake sites.  As that is the case, I will see about getting a more appropriate locked DNS name.  (warpwars.com is taken)

If anyone cares to, come up with potential domain names at godaddy or somewhere else, that might suit the game, and let me know if they are available.  I may (or may not) pick the domain name you chose.  :)

Wednesday, March 13, 2013

The Net Works!

(pun intended)

For the entire project, and experimenting with unity, I have found it impossible to get network communications up and running from Unity Web Player.  Until now.  That's right, the first web edition, with networking is now live!


As it turns out, I used TcpClient, and got it to work on a separate thread.  TcpClient didn't work at first either.  What did work, was to download a Socket Policy Server, install it as a service on my server, and give it a fire wall rule to work.  Since it didn't work until I got the Policy Server running, I'm betting the other methods also work.  (Additional technical note, I added the line Security.PrefetchSocketPolicy, and connected it to port 843 from the client)

So now, I have a lot of commented networking code, which I'll be cleaning up, and probably switch back to HttpWebRequest/Response again, because that should be the easiest method to maintain for all my MVC4 communications.

What's that?  Oh right!  Some of you probably want to try the web game.  Here's the link:

http://warpwars.rr.nu/default.aspx (please note, the server address without the page wont work.  Again, I'm not spending a lot of time on the web, I'm focusing on the game development instead.)

Remember, there is not much to do yet, but you can create an account, log in, and start gaining credits in the resource manager.  Accounts will be wiped after the next significant upgrade.  Also, there is no account info validation/emailing.  You can enter anything you want.  I created an account 'asdf' with password 'asdf', a week ago, so that one has lots of funds available.  Nothing to do with them yet, but its cool to see that resources are growing over time.

Tuesday, March 12, 2013

Network Nightmare...

I'm posting today to let you know about a blocker I'm facing.  I got the Web Version of the game working finally.  One of the selling points to this game is that it will play from the web browser. So this is good news right?

While the graphics did show up, Network communications of any type are failing.  Can't get the server version, can't create new users, can't login and can't obtain resource metrics.  This is a significant issue right now, and I need to figure out how to resolve it.  I'm putting the tile work on hold, and the next external version will be web with networking.

I strongly feel that the web browser aspect is a major sales point for this game.  Similar to Runescape VS World of Warcraft.  Comparably, WoW appears to be the much better product.  But WoW requires a local installation, meaning that you can only play it at a machine you have access to install it.  Runsescape is (or was, haven't kept up on it) Browser based, so you could just run it on any machine you were at.

Runescape has 8.5 million paying members (5.95 per month = 50+ Million / Month)  Now Runescape is far more than just a browser based game, but that is a great reason why people get into it so easily.  You just connect from where ever.  I found out about this, because I was teaching a game on programming back some 6, 7 years ago, and all the kids that were early were playing it on their machines.

Because of the Web by itself being such a strong feature, I intend to keep it.  While there are plenty of City Builder games on the web, how many of them are fully 3D?  (like Runescape)

So in recap, all my attention is devoted to getting the network communications working in the browser edition, then posting it online.  (If I'm waiting for messages, I may continue on the Tiled ground)

Monday, March 11, 2013

Tile Maker Tool

To deal with one of the graphics needs from the previous post, I built a tool that creates tiles from masks.  Masking is a process that lets you grab only a portion of the image, as you will see below, and particularly, I'm using it to help create smoother, more randomizes lines between tiles.  If you look at the previous post, the tiles have razor sharp lines between them, making it painfully obvious that there are square tiles at work.  This tool will help fix that

The images below are not what I intend to use for the game, I just grabbed some temporary images to prove the tool out with (hint hint graphic designers, 64x64 tileable, need dirt, grass, concrete, sand, pavement, possibly a few others but not many. :).

Then I used The following mask images.  (The white shows where the mask is, the rest is translucent.) 

For anyone who isn't aware of how masking in games work, here is an example of how it works when I combine NE with 2.  Starting with a black image, the mask only let the part of the image through that overlapped with the white of the mask.

But even with this one, I was running into a problem.  If you compare the original grass image (2.png) with the masked tile above, it appears very bright.  I wasn't sure why.  To try to debug, I attempted adding a second masked portion.  (3 and NW)

This one looked a lot closer, but there are still pixels that are too bright.  When I combined them things really got messed up.

So I spent a while making sure my equations where right.  with some help from GameDev.Net, I was able to first fix the initial coloring issue, as someone pointed out I had put a '*' where I needed a "+".    Next result:

Now the initial grass and concrete match up better.  But I still ended up with an over-bright section where they mesh together.  The problem was that my first try at this was using a binary equation that actually had no hope of working.  (it works great if there is no alpha blending required)

Original = Original |OR| (New &AND& Mask)
But GameDev.Net came through again, with a better equation, though a bit longer.  (thanks eppo)

Original = ((Original * (255 - Mask)) + (New * Mask)) / 255
After applying this, I was able to get the files fully working, and here is a subset of what the tool created.

The numbers relate to the tile type, and the position relates to the mask.  The order is NE-NW-SE-SW.  0 is dirt, 1 is grass, 2 is concrete, 3 is pavement and 4 is sand.  

From these 5 images, at 64x64 pixels each, with all permutations, came out to 625 images, for a total of 6.5 megs.

To begin with, the download will just include these in the beta, but I'm thinking that I'll have the client request which tiles it needs based on the map it receives.  Either that, or that this tile producing process will execute on the client side later on, which took approximately 3.5 seconds on a 3.3 GHz thread.  But that included save time, which won't be needed on the game client, unless I can cache the images.


Friday, March 8, 2013

Working on: Terrain

Right now, I'm working on Terrain.  Here is its initial draft.

I wanted to achieve a few key concepts with this:

  • Create a grid of tiles, that are some how managed on the client.
  • Randomly assign 2 different tile textures to clearly see the layout.
  • Adjust vertices for a height map.  This image is just done with random heights.
  • Use only single polygons for each square.  (technically two for the triangles)
  • This was built in a separate unity project to experiment with the design/management and not mangle the current code, until I'm satisfied the architecture works.
Work that needs to be done on this:
  • This is generated at random when the scene starts.  I need this to be generated by the server and stored there.  The client will need to load it.
    • I'm presently working out exactly how to save the data.  This probably wont be SQL/DB, but instead be some binary save format
  • Camera scrolling movement.  Keeping the same Y position (height over the map) yet freely sliding across the map.  
  • Camera Rotation.  the camera will keep the same X/Z axis angle, but rotate on the Y Axis (spin left or right)
  • The size will be locked to a small region, perhaps 400x400 tiles, which will be initialized when the map is first created.  I would plan on the player being able to purchase additional land expansions for their city over time, but that is not needed right away.
  • Better land forming algorithms.  This was entirely random, but what I will most likely end up with, is a land mass generator.  
    • Height will be determined in random grid shapes.  producing hills and lakes, instead of the currently jagged terrain.
    • Water will run at Y = 0.  Anything going below that will see the water.  
    • Each GridTile, will hold 4 Land Type Ids.  depending on which type of land it is on any side.  
      • This will be based off of corner, not edge.  I.e.  if to the north it is sand, and the sound it is grass, then this would have the NE and NW corners represented by sand, and the SE and SW corners represented by grass.
    • Textures will be selected based on the 4 land types, and assigning a tile that works for it.
  • A separate tool will be needed to generate the Land Tile Textures.
    • I built a tool like this in VB6 about 14 years ago, but the nature of it is to provide tileable textures for each of the basic types (presuming at the moment that will be Grass, Dirt, Stone, Sand, Gravel, Concrete and Pavement) and then apply a mask to each combination to produce any type. 
    • This has some slight variations, as the VB 6 edition was limited to two basic tiles, and this is increased to four basic tile types.  
What I will need soon:
  • I can continue the development for a while.  So this is not urgent *yet*.
  • I need concept art for how things will look, so that we can agree to it, and start building models and textures off of the same theme.
    • Anyone with graphics skills, I could use the help.  I purposefully am leaving certain details off of this blog, and have additional insight to give, but your welcome to just draft something up and send it as a possibility to use.
    • I'm waiting on finding out more about the graphics skill/interest of those artists who express interest in helping, and make the art/style work with that. 

Wednesday, March 6, 2013

Demo Video 1 - Logging in and Resource Counter




I have a few more enhancements, on my dev build.  Aside from adding company/product name (which will come after figuring out what they are) I'm pretty happy with the log in for now.  Forgot pass/email validation doesn't work, but with how early this is in development, many upgrades will require clearing out all the old player data any way.  Test accounts are easy.




I found out that Unity Assets include a lot of cool things.  Some cost, some are free right away.  I grabbed a ground satellite model that I think is actually a good fit for the game in general, and may remain a basis for presentation.  (MAYBE...   I may sacrifice the quality a bit to make this more web browser memory friendly as the game grows.)


Tuesday, March 5, 2013

Development Log WWCity Client 178 Server 110 (Alpha Build)


I've just completed the first update within the Game Play area.  Most things we will be able to do or not do will be based on how much money and resources we have.  So I created a system that manages a standard set of resources.

http://warpwars.rr.nu/default.aspx - to get the latest client.

All test accounts were cleared, because when users are created now, there is certain data created at the same time about their character.  Minimum levels of resources are set.

Credits = 1000 (+5/min)
Wood = 100 (+1/min)
Stone = 100 (+1/min)
Metal = 100 (+1/min)
Warpium = 0 (+0/min)
Food = 100 (+4/min)
Energon = 100 (+10/min)

Each amount has a starting level, and a certain rate of increase based on your starting base.    Credits are cash.  Warpium is an element that you will build up to harvesting, let alone using.  Food keeps troops/civillions fed.  And Energon is electricity in the form of a raw material.  Places need power to work, you need generators to power them.


Even though the updates are per minute, the actual change is live all the time.  Technically its is a decimal value 20 digits tiny, but the user doesn't see that.  It also only processes growth when it is checked.  It keeps tabs on GameTime, and updates it live.

The client checks with the server ever 5 to 10 seconds to update the values of what you have.  My intention, is that all 3 games will be able to tie into the same resources as a way to support and buffer each area.

Because of the way this is processed, even if you log out for a day, when you log back in, your city will have been producing the entire time.  So when you log back in after a day, even with having done nothing, you will  have obtained 1440 metal, stone and wood.  and even more credits food and energon.

Development Log WWCity Client 121 Server 81 (Alpha Build)

Client 0.0.3.121 is ready.  from the UI, it is almost the same, and it still only allows you to create an account and log in.  No play-ability yet.  The only UI change, is the fact the both Client and Server Versions are now available.

However, one notable difference, is that there is now a download available.  I'm not paying much mind to the site, and it doesn't even have a default link setup yet.  http://warpwars.rr.nu/default.aspx

Web Version Update...  Still not working.  Switching out the communications to remove MS dependencies did not resolve the freezing issue.  Since the windows client is working for now, I will rely on that and move on to game play.

Friday, March 1, 2013

MVC4 JSON Implementation and Bug Hope

News: At my day job, we are learning the MVC 4 C# Server platform.  It's pretty nice and with a few light tweaks  all of its interactions use JSON and GET parameters.

Bug: Chrome (and other browsers) freeze the instant I try running the browser compiled version.  It gets through the initial Unity Loading, and then the unity component freezes, along with the page, and the entire browser as well.  I've done some digging, but yielded nothing helpful.  I can't find any form of debugging info on this, so I'm in the dark to the real problem.  This loads just fine when compiled for Windows.  This occured in IE 9, FireFox Latest, and Chrome.  This was tested on Windows 8 64 and Windows 7 64.

Plan: Without much to go on, my best guess is that it might have to do with the MONO requirements, triggered by using .NET objects like XmlDocument to extract.  I've replaced the server with an MVC 4 implementation using JSON as the communications, and now I'm altering the requests to use LitJson to parse communications, instead of XmlDocument.  I have GetVersion functioning, and now I'm overhauling Login and Register functions.

I'm hoping that with all references to XmlDocument out, that the Web version might execute.  Honestly though, JSON parsing is faster than XML parsing, so this is a good upgrade anyway.

You might ask why I'm using web services/api controllers like this anyway, instead of implementing a UDP client server.  I'm doing this to keep more potential issues out of the mix.  I'm learning Unity 3D with this project, and by using the services, I'll immediately have existing common place protocols, and strong logging built in.  Also, since the project is a City Builder, Real Time responses are not needed.

The city builder will be based off of web services because it does not need any more and web services are easier to farm out than custom built UDP services.

WW Tactics and WW Strategy will require faster connections, and for RT data, I will implement a UDP client server protocol at that time.



Future: If this doesn't fix the browser version, and the Windows version is functioning, I intend to ignore this for the time being, and progress to the Game Play.  I welcome ideas and recommendations on what might be causing the bug or how to get better debug data from the browser.