CivOne - An Open Source remake of Civilization 1

Update as to why there's no new version yet:
The graphics (animations) are smooth now and there's no more gray artifacts when units are moving. I'm still having some problems with the new graphics engine, though.
After yesterday evening, I'm down to 2 bugs: Units not showing some times, and city names or not visible. These should be fixed soon.

I've got mines/roads/railroads working. Goody huts are visible and you can pick them up, but they don't have any effect yet. I want that fixed before I release the next version.

So, there's only about 5 or 6 things to do. Next version will be released soon. :)

Edit:
Down to 2 bugs, only need to fix the goody hut rewards and I need to reimplement clicking.
I did finish two bonus missions though: Palace view and city view are working (sort of). There are no buildings in the city yet, and you can not build the palace, but you can view the city and palace now. :cool:
 
Alright, here's version 0.02 alpha!

Download version 0.02 alpha (mirror):
https://mega.co.nz/#!pJVWjSZQ!jeRUL11r8Nycvab4XBof_iDTqV4r1bG5UN5PzL06D_E

Here's the changelog:
  • Added a configuration tool
  • Reworked graphics system, better colour representation
  • Added the New Game intro/story, including animations
  • Implemented original special resource pattern for the map
  • Fixed: Show correct resources per tile in map overview
  • Added goody huts
  • Added city view screen (no buildings yet)
  • Added palace view (can not build your palace yet)
  • Roads/railroads/mines now fully working
  • You can no longer build ships in cities that are not close to water
  • Units can step onto ships now
  • Temporary: Disabled G button to show Goto cursor (will be enabled when the Goto function is working)
  • Temporary: Press B to instantly finish a unit (will change into buy unit)
  • Added Patch #1: Use SHIFT+LEFT and SHIFT+RIGHT to browse through the intro texts
  • Added Patch #2: Show unit coordinates at the bottom left of the sidebar

There's still some bugs. For one, I tested the game on my netbook and it ran slowly. Please let me know how smooth it runs on your computer and what the specs are. Also, I'd appreciate it if you report bugs.

Here's what I will be working on for the next version:
  • Implement all Civilization advances
  • Implement all (normal) city buildings (no world wonders yet)
  • Allow attacking units
  • Implement the original world generation algorithm
  • Fix coast line graphics
  • Add rivers to the map
  • Play on Earth
 
I get this error everytime I try to build city:

System.ArgumentException: Parameter is not valid.
at System.Drawing.Image._SetColorPalette(ColorPalette palette)
at Civ.GFX.Resources.GetLetter(Byte colour, Int32 font, Char letter)
at Civ.GFX.Resources.GetText(String text, Int32 font, Byte colourFirstLetter, Byte colour)
at Civ.GFX.Resources.GetText(String text, Int32 font, Byte colour)
at Civ.Screens.Gameplay.DrawSidebar(Graphics gfx)
at Civ.Screens.Gameplay.Draw(Graphics gfx)
at Civ.FormMain.FormMain_Paint(Object sender, PaintEventArgs e)
at System.Windows.Forms.Form.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Btw, I know C# + Windows Forms, so I can't wait to get my hands on the source code.:)

Keep up the good work!
 
Thank you both for testing.
I'm not getting the same error when building a city.
May I ask, what Windows version are you using, and do you have .NET 3.5 installed? Also, what version of Civilization do you use?

I think the game will run on .NET 4.0 without .NET 3.5, but it might do some things differently. Also, I've only tested on Windows 8/8.1 x64. If you give me the details, I'll try to reproduce it and fix the error.

I'm moving the release of the source code forward, before I finish version 1.0, but I want to get everything properly documented before I release the source code. :)
 
I am using Windows 8.1 Pro (czech) x64 and civ-0.02a.zip (MD5: 4a0d21853851428b735cbd04660ee205)

Tried installing .NET 3.5, which does nothing. .NET 4.0 installer says the platform is already part of the system.

Steps to reproduce: start game, 4x enter = skip the animation, Chieftain, 7 civs, Roman. Map shows up. Then press "b" to found a city - and the following exception occurs (the same as for hannurabi):

Spoiler :
System.ArgumentException: Parametr není platný. (=Invalid parameter)
v System.Drawing.Image._SetColorPalette(ColorPalette palette)
v Civ.GFX.Resources.GetLetter(Byte colour, Int32 font, Char letter)
v Civ.GFX.Resources.GetText(String text, Int32 font, Byte colourFirstLetter, Byte colour)
v Civ.GFX.Resources.GetText(String text, Int32 font, Byte colour)
v Civ.Screens.Gameplay.DrawSidebar(Graphics gfx)
v Civ.Screens.Gameplay.Draw(Graphics gfx)
v Civ.FormMain.FormMain_Paint(Object sender, PaintEventArgs e)
v System.Windows.Forms.Form.OnPaint(PaintEventArgs e)
v System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
v System.Windows.Forms.Control.WmPaint(Message& m)
v System.Windows.Forms.Control.WndProc(Message& m)
v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Actually, the same error occurs even if you just move settlers around in the first turn (which works), then end a turn with enter.
 
I see, thank you. I was able to reproduce this on my computer now, that means I will be able to fix the problem. :goodjob:

Edit:
In order to get the best results, please use 2x scaling (640x400). There's graphics issues with 1x and 4x scaling. I will fix them in the next version.
 
I have Windows 8.1 as well, but I think I have .NET 4.5 installed. It might be the .NET version or maybe there's still lot of room to optimize your rendering code but the bigger pixel scale I use, the slower the rendering is. For example scale 4 is totally unplayable, it takes minute to the barbarian sail to move.

Maybe it's too late as you already programmed the graphics engine, but I would recommend using for example .NET bindings for SFML library. It's easy to use and powerful multimedia library. You can embed SFML window into Windows Forms component (panel for example).
 
I have Windows 8.1 as well, but I think I have .NET 4.5 installed. It might be the .NET version or maybe there's still lot of room to optimize your rendering code but the bigger pixel scale I use, the slower the rendering is. For example scale 4 is totally unplayable, it takes minute to the barbarian sail to move.

Maybe it's too late as you already programmed the graphics engine, but I would recommend using for example .NET bindings for SFML library. It's easy to use and powerful multimedia library. You can embed SFML window into Windows Forms component (panel for example).

It's never too late... but I've already optimized the rendering engine a lot since yesterday.
The thing is... I needed to make changes to the rendering engine to make the palette cycling possible. I'm not sure if the SFML library is good for this, I'll read about it, thanks! I've also considered SDL and OpenTK (.NET OpenGL).
In the future, I will probably create an option to choose between different engines. For now, though, I'm sticking with GDI+.

I promise, before I release the next version, I will test the game on my really slow netbook. I won't release before it runs the game smoothly at 4x. :)
 
Alright, thanks to Darkpanda's explanation, map generation has been implemented... except for river generation. I will fix the rendering of rivers/coast lines first, then implement "Play on EARTH" and then I will add rivers to the map generation.
Customize world menu is fully functional now.

Really nice to see near original Civilization maps in the game... and I really got to appreciate the sophistication of Civilization map generation. They put some real thought into that.
Theoretically, the algorithm that I translated from darkpanda's thread should also work on smaller and larger worlds, but I will not add support for different world sizes yet.

Edit:
The slow graphics issues are definitely solved now. The game runs at roughly the same speed at any scale now.
 
Can someone help me with this?
I need to figure out how many light bulbs the scientific advances cost each time.

I started counting them but couldn't figure out a formula:
  • First: 11 light bulbs
  • Second: 19 light bulbs (8 more than previous)
  • Third: 25 light bulbs (6 more than previous)
  • Fourth: 33 light bulbs (8 more than previous)
  • Fifth: 41 light bulbs (8 more than previous)

Does anyone know this Civilization secret?
 
Take a look ar the end of this post: http://forums.civfanatics.com/showpost.php?p=9423840

These forums are full of formulas here and there, but not always easy to find though... On a side note, I have been for months (and still am) painstakingly going through the full original CIV.EXE assembly to extract all such game rules, the aim being to be able to create an exact replica just like the one you are building now.
 
Sorry, I couldn't find it, thanks for looking it up for me. It makes sense now.
I couldn't do this without your great efforts. Can't thank you enough for it!

Edit:
I've got all Civilization Advances and the Science Report screen working. Right now the first available advance is automatically selected.
Tonight, I'll be working on the "WISE MEN DISCOVERED" screen and the "What do you want to research next?" popup.
 
While implementing the tech tree into Civ, I discovered an error on this page: http://www.civfanatics.com/civ1/refcharts/civ1techchart.htm
It says Bridge Building requires Iron Working and Alphabet... that should be Iron Working and Construction.

So... the tech tree is implemented, fully working. Including the "Wise Men" screen (both ancient and modern) en the next research popup. Here's some screenshots, also showing the customize world screen and generated world map: http://imgur.com/a/nOSO0

I still need to add poles and rivers to the generated world, fix the river/coastline rendering and add Play on EARTH. After that, I will release alpha version 0.03.

Edit:
I've set up a github account. After version 0.03 I will start documenting the code and focus on releasing the source in github. From alpha 0.04 on, I will release Civ under the GPL licence.
 
While implementing the tech tree into Civ, I discovered an error on this page: http://www.civfanatics.com/civ1/refcharts/civ1techchart.htm
It says Bridge Building requires Iron Working and Alphabet... that should be Iron Working and Construction.
Oh yes, I discovered that bug a while back as well :)

So... the tech tree is implemented, fully working. Including the "Wise Men" screen (both ancient and modern) en the next research popup. Here's some screenshots, also showing the customize world screen and generated world map: http://imgur.com/a/nOSO0

Looks good! Looks like you are making good progress!

I can however see you are making the same mistake in your shoreline rendering as darkpanda is making in JCivED. My guess is you are only using the 16x16 tiles much like all other terrain types? I believe shore rendering is done with the 8x8 subtiles, and then occasionally patched with the 16x16 palette shifting versions.

Edit:
I've set up a github account. After version 0.03 I will start documenting the code and focus on releasing the source in github. From alpha 0.04 on, I will release Civ under the GPL licence.

Awesome! I can take a look at the coast rendering code for you then :)
 
I can however see you are making the same mistake in your shoreline rendering as darkpanda is making in JCivED. My guess is you are only using the 16x16 tiles much like all other terrain types? I believe shore rendering is done with the 8x8 subtiles, and then occasionally patched with the 16x16 palette shifting versions.

*chokes* ... ahem, would you mind to elaborate where you find mistakes in JCivED's shoreline rendering?

As of the latest version(s), JCivED's shoreline rendering is using the original CIV.EXE algorithm to render coasts, using the 8x8 tiles... So your statement made me jump ;)
 
*chokes* ... ahem, would you mind to elaborate where you find mistakes in JCivED's shoreline rendering?

As of the latest version(s), JCivED's shoreline rendering is using the original CIV.EXE algorithm to render coasts, using the 8x8 tiles... So your statement made me jump ;)

Haha sorry didn't mean to make you jump. The version I used a while back had incorrect rendered shorelines, and I verified it by checking the screenshots in your JCivED thread. If you have fixed it since then I apologize and ask that you ignore my comment.
 
Thanks for the help on the coasts... I can't figure them out, whatever I try, the coastlines (especially south) don't look right. If you could explain them, I can still get them in the next version... otherwise you can have a go once I've got the source in github. :)

In the meantime, I've kept going. The following is finished/nearly finished:
  • Intro/credits/main menu (load game/high scores disabled)
  • Fade in/out on new game intro
  • New game welcome text (...you have risen to become...)
  • If you lose the game (by deleting your starting settlers) you will see the Game Over sequence
  • Civilization advances (units will be available/obsolete)
  • Civilopedia for Civilization Advances (page 1 finished, working on page 2)

I've switched to .NET 4.0, because... let's be honest, who still uses Windows XP SP2?

I've been reading about github, I don't think I'll have a problem with getting the project up there. I'm planning on releasing 0.03 alpha within the next 2 days. After that I will clean up the code and add documentation, ready for release on github. :D
 
Thanks for the help on the coasts... I can't figure them out, whatever I try, the coastlines (especially south) don't look right. If you could explain them, I can still get them in the next version... otherwise you can have a go once I've got the source in github. :)

I haven't looked at how CIV.EXE does it but looking at ter257.pic this is how *think* it goes. In pseudo code:
Code:
// Build a bit mask of all 8 surrounding tiles, setting the bit if the tile is not an 
// ocean tile. Starting with the tile to the left as the least significant bit and 
// going clockwise
bitmask = 
  (leftTile != ocean ? 1 : 0)|
  (topLeftTile != ocean ? 2 : 0)|
  (topTile != ocean ? 4 : 0)|
  (topRightTile != ocean ? 8 : 0)|
  (rightTile != ocean ? 16 : 0)|
  (botRightTile != ocean ? 32 : 0)|
  (botTile != ocean ? 64 : 0)|
  (botLeftTile != ocean ? 128 : 0);

if (bitmask == 0) {
  // This means the tile is surrounded by ocean, so simply draw the ocean tile with
  // no coast

  // screen_x, screen_y, sprite_x, sprite_y, width, height
  drawImage(0, 0, 0, 176, 16, 16); 
} else {
  // There are at least one surrounding tile that is not ocean, so we need to render
  // coast. We divide the tile into four 8x8 subtiles and for each of these we want 
  // a 3 bit bitmask of the surrounding tiles. We do this by looking at the 3 least 
  // significant bits for the top left subtile and shift the mask to the right as we 
  // are going around the tile. This way we are "rotating" our bitmask. The result 
  // are our x offsets into ter257.pic
  topLeftSubtileOffset = bitmask&7;
  topRightSubtileOffset = (bitmask>>2)&7);
  bottomRightSubtileOffset = (bitmask>>4)&7);
  bottomLeftSubtileOffset = (bitmask>>6)&7)|((bitmask&1)<<2);

  // screen_x, screen_y, sprite_x, sprite_y, width, height
  drawImage(0, 0, topLeftSubtileOffset<<4, 176, 8, 8);
  drawImage(8, 0, (topRightSubtileOffset<<4)+8, 176, 8, 8);
  drawImage(8, 8, (bottomRightSubtileOffset<<4)+8, 176+8, 8, 8);
  drawImage(0, 8, bottomLeftSubtileOffset<<4, 176+8, 8, 8);
}

Perhaps Darkpanda can verify that this is correct? The algorithm for determining if a tile should be replaced with the animated shore is unknown to me.

I've been reading about github, I don't think I'll have a problem with getting the project up there. I'm planning on releasing 0.03 alpha within the next 2 days. After that I will clean up the code and add documentation, ready for release on github. :D
Github is awesome! :)

When other contributors want's to contribute to your project they make a "pull request" which is basically a request for you to accept their code into your project. You can then review the code and comment on it, and when it's up to your standard you can merge it into your project with a single click.

If you haven't worked with git before you probably need some time to adjust to the whole concept of local repositories, but once you get the hang of it you're going to love it!
 
Top Bottom