Wednesday, October 27, 2010

Video of the tilegenerator

As promised before here's the tilegenerator in action:


The plan for the upcoming days is adding multiple layer.

Skipping Particleengine

I decided to skip the particleengine for now.
I will continue the work on the tilesystem.

The reason for skipping the particleengine is that I finally want to have something
playable.

The good thing on the tilesystem is that I can adept the most of it from an old schoolproject I was working on about 3 months ago.If everything works fine I can upload a video of the tilegenerator within the next hour.

Tuesday, October 26, 2010

Problem solved once again....Somehow

I figured out the error really quick.
The problem was that when the last object got erased from the list via

i = Timers.erase(i);

the iterator pointed to the space equals to Timers.end().
The for loop then incremented the iterator and voila you get an pointer to undefined memory.

I don't know why the for loop didn't jumped out at this point even though
the stop condition for the loop is

i != Timers.end()


After I added the following line at the end of the for loop, the error disappeared.

if(i == Timers.end())
break;

Monday, October 25, 2010

New problems to solve...

Today I tried to program some "CreateNew" functions for my classes/structs.
The idea behind that was that I wanted to add newly created objects to an array so they get processed automaticly.

The code looks like this (in this case the timer class):

Timer *CreateNewTimer() {
Timer *pRet = new Timer();
pRet->EraseMe = false;
//Some more initializes
AllTimers.push_front(pRet);
return pRet;
}


In the main function there's a function "CheckAllTimers" which looks like this:

for(auto i = AllTimers.begin();i != AllTimers.end();i++) {
if(!(*i)->EraseMe)
UpdateTimer((*i));
else {
delete (*i);
i = AllTimers.erase(i);
}
}


But somehow I get an error when the timer gets erased from the array (in this case a list)...I tried to fix it for 2 hours...(I used to use vectors and hoped that the error disappears if I switch to lists...But that didn't do it.). I'm pretty damn sure that it has something to do with

i = AllTimers.erase(i);

and I'm also pretty damn sure that something like

if(i != AllTimers.end())

will fix the error but I'm too tired right now to invest more time on trying to fix this error.

Friday, October 22, 2010

Started working on the particle engine

I started working on the particle engine for my 2D engine about 3-4 hours ago.
I'm making pretty good steps although it's way more complicated than I thought.

Here's a little video of me testing the particle engine.



The next step would be to implement something like physics and spreading.
(Which is the hardest part though)

Wednesday, October 20, 2010

Not to see the wood for the trees

I *finally* fixed an error I was trying to fix for like 4-5 days.
The *error* was sooooooooooooooo stupid that
I don't understand how I couldn't have seen that.

I tried to implement my timer module (a simple countdowntimer) in the scripting language Lua.

To test if the implementation works correct,I wrote a little testapplication in Lua which just creates a new image and draws it on the screen for a specific amount of time.My problem was although the timer had stopped the image was still visible...I tried nearly everything to make it work but I failed over and over again.

Yesterday I realized that I forgot to draw a background in the testapplication.
The test-image (a tiny little ship by the way) was still visible because there was nothing that drew over it. Sooooo stupid -.-

If someone cares, here's the script:

function Start()
testsurface = Surface.New("Ship.bmp")
testtimer = Timer.New(3000) --3000 is the time
--in milliseconds the timer's running
end

function Update()
if Timer.IsRunning(testtimer) == true then
Graphics.Render(testsurface)
end
end

Monday, October 18, 2010

Problem solved

I solved the linker problem from yesterday (last post) with a strange workaround.

The following 3 lines were the key to success:


#ifdef main
#undef main
#endif


I will stay with this for a while, but if I have some free time I will try to fix it.
I'm not a big friend of such workarounds...There must be a way to run this main-stuff properly.

Switched to MS Visual Studio 2010

Today I realized that I can download 'Visual Studio 2010 Professional' for free with my msdnaa account.I read that many dev studios are working with VS, so I thought that it wouldn't be a bad idea to install it and get used to it.I worked with 'Code::Blocks' (using MinGW compiler) so far and really felt in love with it so I was a little suspicious and scared when I started the installation.

After the (way too long,but not too boring (thanks to my PSP ;) )) installation I imported some *.h and *.cpp files from my CodeBlocks project (a 2D-Engine) to the new VS2010 project.

After I set up the lib-/ and include dir I started to build the project...

I expected the project to build properly (as it did in codeblocks using minGW) but after a few seconds some (and by 'some' I mean infinite) linker error appeared. I now spent like 1-2 hours to finaly got rid of them.

After I (finaly) build the *.dll and *.lib from my engine with VS2010 I started to program a little test application to test some functions from the 2D-Engine.

The engine is using SDL for eventhandling and graphics-stuff.The thing about SDL is,that it declares its 'own' WinMain() function.There's no need to call a WinMain,if you're using SDL...You just need to call main(int args,char args[]) (or something like that).That's easy to use and should normaly work but now I get another linker error caused by the main() function. I'm now sitting here for like 2-3 hours in total just fixing some linker errors and starting to slap my own face for switching to VS2010...I hope I get used to it soon.

Oh and btw: welcome to my new blog ;)