Knuckle Cracker

Creeper World => Suggestions => Topic started by: Grun on April 02, 2013, 09:20:15 AM

Title: Creeper World 3D.... again
Post by: Grun on April 02, 2013, 09:20:15 AM
Hey all, been a while.

Some may remember this thread...
http://knucklecracker.com/forums/index.php?topic=7465.0

and in that these videos...

https://www.youtube.com/watch?v=Ns8g9r69hkw
https://www.youtube.com/watch?v=COsIDNSrRjI

Well I left it there and been getting on with real life things, as per original thread I got married and since had a baby :) little girl who nearly 12 months old now.

But was just killing time and was playing CW and thought lets check out any updates and CW3 :O but I have to wait so till then I been doing a little more on that 3D demo sim...

http://www.youtube.com/watch?v=OR44Y0lj8_o&feature=youtu.be

What people think??? I know things like the lazer postion compltly needs reworking and scale/timings need fine tuning and its still my legendary art work :P

Hope all enjoy and looking for ideas about what to include next

Grun
Title: Re: Creeper World 3D.... again
Post by: Grauniad on April 02, 2013, 12:06:44 PM
Well, congratulations with your "real life". :) Little kids are fun!

I'm sure you have checked out the Knuckle Cracker blog to see where Vigil has gotten to. Still 2D, but with some light and shadow effects to give some 3D feeling to the game. There is still the requirement that the game be written in something that can be supported from a browser and on some of the gaming websites such as Kongregate, so not all the freedom to choose platforms that one may have wished for. The new Unity3D platform gives a lot better performance and that you will see in the increased detail and general feel for the game when you watch the videos.
Title: Re: Creeper World 3D.... again
Post by: Grun on April 02, 2013, 01:31:40 PM
Yeah have watched all vids (some a few times :P ) and love the new look and feel, this program I have written is sort of a test bed to test skills.

There a lot lot more to it than what you see such as lighting effects i been messing with, colour picking (for unit selection), UI overlay etc. I just find programming I need some results I can see and show off etc so CW works well.

Grun
Title: Re: Creeper World 3D.... again
Post by: TrickyDragon on April 02, 2013, 01:38:26 PM
Interesting,  do you have variables for liquid thickness and whatnot?
Title: Re: Creeper World 3D.... again
Post by: Grun on April 02, 2013, 02:17:29 PM
Well sort off, its a calculation of height aboved terrain making it easyer when doing the calculations for the creeper to climb/fall over cliffs. This also works nicly for the blaster to do calculation for damage done as a reduction in height of creeper at area hit.

Grun
Title: Re: Creeper World 3D.... again
Post by: thepenguin on April 02, 2013, 09:35:43 PM
1. what language is this in?  I beleive it was some kind of basic, but I'm not sure...
2. any chance of source code getting shared?
3. is this just a height map, like virgil's "3D creeper", or is it a real 3D simulation? I beleive that it was just a height map last I checked, but I want to make sure it hasn't changed.
4. your blasters are beyond awesome looking (i don't know what it is about them.)
Title: Re: Creeper World 3D.... again
Post by: Grun on April 03, 2013, 04:54:50 AM
Hi Penguin,

Its written in c++ using openGL,

As for source code there a lot that needs rewriting and sutff unrelated to it as it is at the moment and well its huge :P

As for the creeper covarage, its simply a triangle strip for the terrain and one of same dimensions just below which raisees for where the creep is raising increasing the opacity and distance between terrain and creep as it rises. So it is 3d in respect that you can look at diffrent angles and it will display as such. Will go into more detail at bottom of post....

As for the blaster model, well it took about 20 minutes but was created in 3DsMax and a simple texture just put on. Im not as good as I use to be at modeling but have used models with up to 5000 poly count and still get high FPS so to swap it out is just a simple case of creating a new model which looks better and done.

Grun.


Firstly the terrain, creeper very similar code.... ignore the stuff relating to parent unless you know much OO, but as you can see it uses GL_TRIANGLE_STRIP which works like this image..(scroll about half way down for image)

http://stackoverflow.com/questions/2954349/when-should-i-use-indexed-arrays-of-opengl-vertices#

Terrain Constructor
Spoiler

Terrain::Terrain(const char* filename, const char* texture)
{
   
   baseHeight = 8;

   Image* image = loadBMP(filename);

   //width + length taken from size of bitmap
   w = image->width;
   l = image->height;
         
   hs = new float*[l];
   for(int i = 0; i < l; i++) {
      hs = new float[w];
   }
   normals = new Vector*[l];
   for(int i = 0; i < l; i++) {
      normals = new Vector[w];
   }
   
   for(int y = 0; y < image->height; y++) {
      for(int x = 0; x < image->width; x++) {
         unsigned char color =
            (unsigned char)image->pixels[3 * (y * image->width + x)];
         float h = baseHeight * ((color / 255.0f));
         hs[y]
  • = h;
          }
       }
       
       g_Game.addRenderComponent(this);
       

       mTexture.Load(texture);
       
          
    }
[close]
Terrain::Render
Spoiler

void Terrain::Render()
{
   // dont render if we dont have a parent (so we dont have a transform)
   if(!getParent()) return;
   
   mTexture.MakeCurrent();
   
   for(int z = 0; z < w - 1; z++) {
      //Makes OpenGL draw a triangle at every three consecutive vertices
      glBegin(GL_TRIANGLE_STRIP);
      for(int x = 0; x < l; x++) {

         Vector normal = getNormal(x, z);
         glColor4f((getHeight(x,z)/baseHeight),(getHeight(x,z)/baseHeight),(getHeight(x,z)/baseHeight),1.0f);
         glTexCoord2f(x/w, z/l);
         glNormal3f(normal.x, normal.y, normal.z);
         glVertex3f(x, getHeight(x, z), z);
         
         normal = getNormal(x, z + 1);
         glColor4f((getHeight(x,z)/baseHeight),(getHeight(x,z)/baseHeight),(getHeight(x,z)/baseHeight),1.0f);
         glTexCoord2f(x/w, (z+1)/l);
         glNormal3f(normal.x, normal.y, normal.z);
         glVertex3f(x, getHeight(x, z + 1), z + 1);
      }
      glEnd();
   }
}
[close]

As you can see in the constructor it passes 2 arguments for the 2 textures needed, 1 used for the height map and the other the texture to render over the top.

Creeper is created and drawn in almost same way, just has a pointer to the created terrain and is able to use function getHeight(float X, float Y) and the creates the height at each point like 0.001 below. Then the emmiter gets the creeper height at its position and adds to this height at set values and time intervals. This then causes it to go into calculations for how much to pass to ajoining areas. This code is messy and still being worked on.

Also for all these people looking at this code and seeing stuff like, g_Game.addRenderComponent(this); , yes i know its nasty using external reference and there better ways but im still learning :P
Title: Re: Creeper World 3D.... again
Post by: Grun on April 04, 2013, 07:05:03 PM
Still working on it :)

have added a UI with buttons which show when highlighted and detect click, now I just need to make the click do somthing :P

Will keep you up to date with any other advances.

Grun

quick edit...

Just for people who dont know/remember...
this is just for fun im doing this and have no intention of doing anything with, other than mess about with myself, have spoken to Virgil about such back when I first started :)

Then again.... if I made like the best of games to beat even the $100000000000 games out there im sure Virgil would be happy to negotiate :P
Title: Re: Creeper World 3D.... again
Post by: Kingo on May 31, 2013, 01:15:19 AM
Can we get an update grun? :)
Title: Re: Creeper World 3D.... again
Post by: Grun on July 01, 2013, 07:49:46 AM
Pretty boring stuff unfortunatly.

Been altering the code for models to allow for each model to be made up of multiple models with multiple textures, allows for a lot more detail.

Also looking to add other units, but to do so need to rewrite older code (making a factory class for anyone who knows about programmining). This will allow me to say build unit A at location X,Y in one line of code which can then be execuited at any time through commands while its running. Once this sorted will tie it in with the UI elements I introduced so it works like it would in game, click what to build and click where to build it.

Im also in process of looking at introducing the variables to be taken from external file, this will allow for easyer changes to behaviors of things rather than looking through 10,000s of lines of code :P

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 02, 2013, 12:56:53 AM
What can the program do?
I myself am into programming right now, so it isn't boring for me :)
Title: Re: Creeper World 3D.... again
Post by: Grun on July 02, 2013, 07:03:00 PM
Ok lets see......

Well it basic openGL framework which handles, well openGL and some of the lighting etc...

Then there a base class which holds a Matric and virtual routines for creation, destruction, update and render if it inherits of a render component. All classes that inherit of this class get added to a list, a seperate list for anything which is rendered. The each frame each item in these lists get the function update(time) and where applicable renter() run.

From there a simple camera class which uses external references to the mouse position (I know this nasty needs changing) but each aspect of the camera (XY movement, zoom etc) which alter the inherited Matrix to then be passed to open GL to set camera.

Next there a terrain class which uses openGL triangle strips setting the height via a BMP using RGB to determin the height.

Directly below that is a 2nd plane which is like .01 below the terrain which acts as the creeper. This is then set globaly via the main game class to allow all to have access (again nasty) so other classes such as the emmiter can increase. This class also then references the terrain class to calculate if above the terrain to have the spread logic take place.

Then the cannons (and similar for others), well at min they take and X Y position and take the terrain height from such position and place a model which im currently using Quate models. There is multiple models so the turret can be rotated spearatly through the inherited base class for rotation and can allow for more detail and easyer UV mapping. There then a further component which looks to see if any creeper above terrain within a set radius to the rotate the top half/set parts of the model to face this area and then fire, setting of a timer till nexxt shot available and reducing the creeper level at that point.

The UI stuff etc im working on cant explaing much as messing about with that quite a bit.

Depeding on your level of programming you may or may not follow or understand why having both the terrain and creeper being global (well not global it just having reference to it in the main game class).

If there any specific aspect you want more on just ask and will try and explain.

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 03, 2013, 05:38:59 PM
I understand the need for global and local variables :) definitely annoying, but essential.
I can see with making them global, you don't need to run a calculation (if it is as simple as that) to continuously check each terrain height for whether the creeper should rise...

I ran into this problem when I was considering trying to emulate CW in Excel using VBA.
Title: Re: Creeper World 3D.... again
Post by: Grun on July 04, 2013, 05:31:38 PM
Global variables are not essectial, there is always ways around such as sending pointers to what the class needs. I didnt actualy set them as global I set the main game class as external in the class so the classes that needed access could do so through the main game classes pointers, so for the terrain creeper and mouse etc. 

As for doing such in excell, dam would be pretty hard.

If there any more detail about any aspect just ask and will try and explain in more detail or provide some of the code to show how i done it.

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 04, 2013, 06:15:05 PM
Currently I've been trying to make Galaga (anyone here know what it is?) work in excel, it's actually doing good... I am a bit wet behind the ears in terms of general programming and its terms, but I am picking it up time to time :)

What programming language and/or API are you using?
Title: Re: Creeper World 3D.... again
Post by: Grun on July 05, 2013, 11:52:13 AM
Written in C++ using openGL using 3dsMax for models and PS for textures.

Grun
Title: Re: Creeper World 3D.... again
Post by: MadMag on July 05, 2013, 11:53:57 AM
Wish I could have had time to learn 3dsMax better :/
Title: Re: Creeper World 3D.... again
Post by: Grun on July 05, 2013, 04:15:02 PM
Mad I know you amazing art skills, both map and 2d. Best bet is start with gmax. Think of models in 2d and draw with lines and extrude then just mess with vertecies. gmax has a lot less optitons so this should be quite easy with someone like you. Then take it from there.

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 14, 2013, 02:41:57 PM
Hey grun, could we get a video update if its not too much to ask?
Title: Re: Creeper World 3D.... again
Post by: Grun on July 14, 2013, 06:25:33 PM
lol Kingo.....

Well what you want to see next in a vid and depending on how complex will put somthing together...

As for timescales.... well been very busy but should have a few hours over next few days so will see what I can do once I get ideas of what next.

Grun
Title: Re: Creeper World 3D.... again
Post by: Karsten75 on July 24, 2013, 09:38:08 AM
Quote from: Kingo on July 04, 2013, 06:15:05 PM
Currently I've been trying to make Galaga (anyone here know what it is?) work in excel, it's actually doing good... I am a bit wet behind the ears in terms of general programming and its terms, but I am picking it up time to time :)

What programming language and/or API are you using?

Only one question: Why the heck would you program a game in Excel? I see posts of you all over the forum regarding your activities in this regard and it seems bizarre to say hte least. Performance should suck, the platform isn't suited and few people have Excel installed.
Title: Re: Creeper World 3D.... again
Post by: thepenguin on July 24, 2013, 10:01:44 AM
Quote from: Karsten75 on July 24, 2013, 09:38:08 AM
Only one question: Why the heck would you program a game in Excel? I see posts of you all over the forum regarding your activities in this regard and it seems bizarre to say hte least. Performance should suck, the platform isn't suited and few people have Excel installed.
Because he can.  It's also a very common platform to be operating off of.  It certainly is installed on more computers than something like unity or air (which these games are based in).  While not the most common of platforms, it is certainly more common than many others.

Also, I doubt that an excel spreadsheet gets worse performance than the atari that these games were first played on.
Title: Re: Creeper World 3D.... again
Post by: Karsten75 on July 24, 2013, 10:45:17 AM
Quote from: thepenguin on July 24, 2013, 10:01:44 AM
Quote from: Karsten75 on July 24, 2013, 09:38:08 AM
Only one question: Why the heck would you program a game in Excel? I see posts of you all over the forum regarding your activities in this regard and it seems bizarre to say hte least. Performance should suck, the platform isn't suited and few people have Excel installed.
Because he can.  It's also a very common platform to be operating off of.  It certainly is installed on more computers than something like unity or air (which these games are based in).  While not the most common of platforms, it is certainly more common than many others.

Also, I doubt that an excel spreadsheet gets worse performance than the atari that these games were first played on.

Kingo made you his spokesperson?

And as you should well know, you don't need to install anything on a computer (except the game) to run a Unity-based game.
Title: Re: Creeper World 3D.... again
Post by: Ronini on July 24, 2013, 11:52:33 AM
Although I can't speak for anyone else, I know that sometimes, you just need to do something immensely hard, inefficient and/or pointless, for no other reason than to prove that you can.
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 24, 2013, 11:58:54 AM
First of all, it's the only programming language I know of.
Second of all, I would like to do it as a challenge, and for experience.

And yes, I do know that performance on it is not too great, that is why I am trying to EMULATE it as best I can in excel.  
Admittedly you can download arcade game emulators that can run it at a good speed... but I want to program it in excel for the challenge and experience of it. It is possible, it just takes time and workarounds are needed often. I am doing it more for myself rather then to release the game, because a better version already exists, but it still is decent (for a game in excel suited to its caliber).

I believe, though, that this argument should have been taken to private messaging rather then this thread, as I know that Graunidad will be here as soon as I am done posting (as he seems to be all-knowing and all-seeing, lol) and threaten to lock this thread if we don't get back on topic.
Title: Re: Creeper World 3D.... again
Post by: thepenguin on July 24, 2013, 02:13:37 PM
Quote from: Karsten75 on July 24, 2013, 10:45:17 AM
And as you should well know, you don't need to install anything on a computer (except the game) to run a Unity-based game.
Unless it has browser-based content, in which case there is an install required.
Title: Re: Creeper World 3D.... again
Post by: Grun on July 24, 2013, 08:12:15 PM
The actual language/platform etc. you use to create is not important when doing such for your own development/pleasure. From what I know about excell it is basicly visual basic (may be wrong) which is an objext orintated language. Once you get your head around OO and the advantages/problems from such the language it self is not as much of an issue. For example the main diffrence between say C++ and C# is the releasing of memory, the rest is pretty much sintax. The hardest part is looking at the logic, maths and physics and how to incorporate that into the OO structure you are using.

The odd thing is I think using excell/VB there is some advantages which is the ease of introcing complex equations which I imagine excell would be pretty efficent at (again may be wrong here)

With sim im making im looking at the pathfinding for packets and there requests. This is great example of the diffucltys with OO and this is same problem with all languages. The way it works is simply a method called A* (A star) which determins the route to take by looking at distance traveled between nodes and distance as crow flys to destination and then working both back and forward looking for which would be next shortest till it reachs destination (hard to explain in 1 sentance, google it if you want more detail).

Now I know there at least 1 person reading wanting to know how im planning (may change) this into my structure....

Well.... Each object when created will look for any objexts in radius X (not sure if to consider the Z axis) then from there adds a pointer to a list of all in range and then from that adding itself to the objects lists in that list so each link is referenced both ways.

From that we will know the source being the main hub/base and destination would be a call from the structure requireing a packet.

From there it gets quite complex reuireing either multiple lists with one list being visitied and one being available or a struct being created with a pointer to the object and a bool for used or not. Im thinking the latter with a struct with...

(baseObject object*, bool visited, baseObject* cameFrom) 

then working thorough each nearest not used step gets to destinationa and can use the cameFrom and repeat such till it gets to source adding each time to a list and you end up with a list of route to take. Then it about sending a packet at set speed along such route and updateing destination for such on arrival.

Now the hard part..... what happens if a object is destroyed along the route it would have taken???? well the object would be removed from game and then the pointer would be to nothing and cause a crash.... you could iterate through the list and remove any reference to such but that would be quite intesive if there a large number of objects on the map.... I have thought of a few ways for such but it quite messy so still thinking.....

Dam that was more than I intended to type :P

Grim
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 25, 2013, 12:07:03 AM
I don't believe there is a difference in improved performance of calculations..
The processor first has to cycle between all processes on the computer, then excel, and then the visual basic macro. It doesn't get its own process (since the VBA macro is not an application like Excel or Creeper World).
If the macros and excel in general ran faster, then it would probably be a decent (if not used often) API for programs (for novices who are either starting out with programming like me, for instance, to build their programming skills. I learned patience with bugfixing, for instance).

VBA is a lot simpler to learn with the Macro recording tool, anyways, and you can write functions knowing a small amount of the syntax to do many things since the screen is made of cells (column and row heights/widths can be adjusted to emulate a decent-looking screen made of pixels, except when you zoom or scroll excel takes a bit of time to render them out).
I don't believe the processing speed can be helped, though, but my computer is old, so I'm not sure if performance can be improved or not with a better computer.


it's more about the API you are using rather then the programming language most of the time... anyone can pick up a programming language, but to apply it to a game, you need to have an API, and fully understand it as well. Artwork is also quite important, as there is no game without artwork.

@Grun
Sounds interesting :) I understand your line of thought, quite a few times I've tried to write up  code for a function, then, when I realize it's too messy to fix and bugs keep popping up , I've had to delete it and start over, letting the problem simmer in my subconscious.
Title: Re: Creeper World 3D.... again
Post by: Grun on July 25, 2013, 08:03:43 AM
Yup Kingo,

That the point im at with A* just thinking the problem over.... I could introduce something that would work now but would create a lot of problems potentialy when I introduce the destruction or moving of objects.

As for where you at with programming and excel, sounds like you need to look at moving away from excel and look at VB, you mention you like using the screen made of cells being able to reference them by coloum and row.... well this is very very easy to create, would be something as simple as creating a 2 dimensional aray of a class called cell which then depending if each cell same size or not to draw just using the references from the array to draw. eg.. in excell you reference A3 this would be cell[0][2]. Thing is these cells can be anything, such as say creeper :) which each cell has a value it is above the terrain so things like cell[0][2]->addcreeper(10); as you can see it seems pretty easy :) as for how the addcreeper(10) works well again that easy enough, it simply takes the existing value of creeper at that cell and adds amount passed. So from that simple bit of code you have a simple reprensentation of what could be used as values for creeper over the whole map, then it just a case of drawing such which is a little more comlpex.

If you interested in learning more I would advise looking at http://nehe.gamedev.net/ which uses openGL and available in VB (although the info explain the code is in C++). This teachs you a lot about the graphics side. Go through some of that and look into openGL triangle strips and you would very quickly be able to create somthing similar to what I got so far excluding the 3d models and code structure.


Grun
Title: Re: Creeper World 3D.... again
Post by: thepenguin on July 25, 2013, 09:33:56 AM
Quote from: Grun on July 24, 2013, 08:12:15 PM
Now the hard part..... what happens if a object is destroyed along the route it would have taken???? well the object would be removed from game and then the pointer would be to nothing and cause a crash.... you could iterate through the list and remove any reference to such but that would be quite intesive if there a large number of objects on the map.... I have thought of a few ways for such but it quite messy so still thinking.....
If the pathfinding is an object method of the Unit object, when the unit is destroyed, the pathfinding logic also goes away.  Unless you mean one of the nodes you pathfind between, in which case a simple check for a null pointer should be able to fix it.  or, instead of removing the unit, you change it to a null unit, which can be evaluated, and the path discarded.
Title: Re: Creeper World 3D.... again
Post by: Grun on July 25, 2013, 06:38:34 PM
Yes Penguin,
but how would you check for such???? Think about it say there 200 packets currently in circulation with an average of 10 nodes to visit each that a check for each time a unit destroyed which would be quite intesive and cause potential lag (well on lower end comps). Now another alternative is to have the node itself a list which contains a of all packet requests which use's itself, this way it only needs to go back on destruction to remove that one packet (or multiple if multiple nodes packets using itself) which in turn can fire the request from the reciver for another packet. This way it would only be intensive if it was a high traffic node such as the ones near comand centre which are less likly to be destroyed. This would be a lot more code but would be a lot better for performance, this is the way I belive I will introduce (when I get chance, just started a new job :P ).

This is what I was trying to explain about the complex aspects of programming, it not the code or API more the logic. It also the thing which I love about programming as I imagine most game programmers do (well it love hate sort of thing).

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on July 25, 2013, 07:01:41 PM
You hit it on the head, grun.
The logic is what makes games unique and fun, and can make programming fun too, but it can be a real annoyance at some times.
Title: Re: Creeper World 3D.... again
Post by: thepenguin on July 25, 2013, 08:09:50 PM
I'll leave it to you, as I don't have the source code to make a judgement on whatever kind of mess you have there. :)
Title: Re: Creeper World 3D.... again
Post by: Grun on July 26, 2013, 06:36:00 PM
lol penguin :P

you seem to know your code so will try and explain as quick as i can.....

I have list of all objects including the terrain camera and creeper, these are base classes so have multiple which inherite off which dont effect this proble. Each base class has a matrix so that how to get position of each.

So im thinking..... Take the start and end location and pass to a function, this function would create a duplicate of the object list (may look at way of remofing non route stuff) and take it from there. Other than that im very open to ideas.

Grun
Title: Re: Creeper World 3D.... again
Post by: Ninja on July 29, 2013, 11:46:30 PM
I have nothing to say on the coding conversation. :-X I have everything to say on the game and how awesome it looks so far. Keep going, Grun! It looks AMAZING! I'd love to play a 3D creeper world.  ;D
Title: Re: Creeper World 3D.... again
Post by: Kingo on August 17, 2013, 09:29:24 PM
Grun can we get an update?
Title: Re: Creeper World 3D.... again
Post by: thepenguin on August 17, 2013, 10:13:42 PM
I was giving the packet routing more thought, but I can't come up with anything better than what you have.
Title: Re: Creeper World 3D.... again
Post by: Grun on August 23, 2013, 06:11:44 PM
Yup penguin think that best I could manage so will look at doing such :)

Kingo, this is just somthing I do in spare time, I will try and best update but lots of other things get priority, will try and do some small quick flashy updates for visual effect but it when I get chance. Still messing with code for the pathfinding, i could get somthing that worked very easy for a demo but I stress test to extreme lengths all I do (tryed a demo with 1000 blaster and still got resonable framerate :) which I didnt record till I had such). There no point in programming just for a video/demo for games. If I get chance Im currently messing with particle effects on other projects, will try and add such to the shot collision with creeper (and sort out height for shot from blaster), that way I can get an update sooner, but you know plans change very quickly. Also..... CW3 on the horizon, think that will put a big delay on this by quite a while :P . Dam Virgil I want CW3 :P

Grun
Title: Re: Creeper World 3D.... again
Post by: Kingo on August 25, 2013, 04:56:56 PM
I understand Grun :)
I myself am working on a 2D shooter game, so far i've been making graphics for my game, and its a relaxing experience.