(Help Request) Hello! can you help me?

(1/4) > >>

im currently creating my first win32 gdi game but im having a problem with it. When i run the game it runs well but after a few seconds (maybe 30 seconds or more) it then crashes.

pls help me solve this problem.

here's the source code:

i hope i didn't break the forum rules by posting it here.

Richard Marks:
Welcome! Welcome!
:) I'd really like to know how you found our forums.

I'll do my best to help you out.
Let me download the stuff and I'll post again after I've checked it out.

You didn't break any rules.
Okay, let me go see this source

I attached the original source to this post for anyone else who wants to help -- because rapidshare can be a pain

Two things you should fix that I noticed immediately.

        // BAD CODE -> delete[] rectMain;
* Explanation:
* You were trying to delete an array, which is wrong.
* You allocated a NON-array variable for each element of an array of 2 RECT pointers.
* So you need to delete the two pointers, only if they are not zero.
if (0 != rectMain[0]) { delete rectMain[0]; }
if (0 != rectMain[1]) { delete rectMain[1]; }


        // BAD CODE -> delete[] weaponList;
* Explanation:
* You were trying to delete an array, which is wrong.
* You allocated a NON-array variable for each element of an array of 2 CWeapon pointers.
* So you need to delete the two pointers, only if they are not zero.
        if (0 != weaponList[0]) { delete weaponList[0]; }
        if (0 != weaponList[1]) { delete weaponList[1]; }

I'm not experiencing any crashes, so I am not sure why you are.
I will go through your code with a fine-toothed comb later.
But I really think that you would benefit by learning to comment your code, and write modular code properly.
I'd be happy to teach you. Its what I like to do. :)
Join me in our IRC chat room.


wow! you're really cool, thank you for pointing that out. Surely i will take note of that. BTW, i found your forum in RPGDX, not a regular member there but i always visit and view threads whenever i get my hands on the keyboard. I didn't know you have this forum. I just accidentally discover it from Captain's thread.

about the problem, i tried running the game on other machine and the result was the same. It crashed after a while (not seconds, maybe a minute or two of waiting).

sorry i didn't leave comments on my source code, im having a hard time writing english. take this post for example, it took me 40min to compose.  ;D ;D

if you have time and if it's not too much to ask, can you reconstruct my code? so that i can study it.

im looking forward to learning from you.

Thank you, Master!

Richard Marks:
I'm glad you joined my forum. You're more than welcome to stick around, and learn, ask questions, get help with stuff, and just have fun in general. :)

Now, I'm quite puzzled as to why you are getting crashes.
What operating system are you using (windows 98, 2000, ME, XP, vista, etc), and what are your system specifications (ram, cpu, video card, etc)

I tested your code in XP running in a virtual machine since I use Linux for my main operating system.
Perhaps its because I'm using the virtual machine that your code isn't crashing? I'm not sure.
Tell me your specs, and I'll see if I can get my hands on a similar system to test in native windows, not a virtual machine.

40 minutes! WOW...thats a long time to write such a small post...
Where are you from? Maybe you need to take English lessons too. I'll keep an eye out for any good programs for that. :)

Its not too much trouble, and I'll happily do that; but I need a little time for it.
I'll be busy most of the weekend with other things, however Sunday night / Monday I will have time to sit down and go over your code line for line, refactoring the code in a more professional manner, so that you can learn. One thing I will warn you of is I will refactor your code using my coding standards.
There is a thread here that you should read so that you will be able to follow my code style.

Code Style:


I'm not sure if you did or not, but it looks to me like you copy/pasted large parts of your code from different places. If you didn't do that, then you really are in need of some coding standards.
Use mine. They are simple, and very readable. :D

Again, you are welcome. .. hehe "Master" .. I like that :D

I'll keep you informed of the progress.

haha! it's not actually 40min... 20 i guess. Yes, some part of the codes are taken from my old GameTutorials CD i bought, particularly the TransparentBlit function, the fmod source, and ofcourse the win32 template of CodeBlocks, other than those it's all mine. I'm using WinXP service pack 2. Well, it's not too important to me why it's crashing.. right now i am more concern on structuring my code properly. I want to see how a master like you restructure this one and hopefully learn from it. Anyways, i am from Philippines.


[0] Message Index

[#] Next page