Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / My engine is working at 4 fps Why?

Author
Message
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 9th Jun 2012 21:48 Edited at: 10th Jun 2012 11:18
Hello all TGC community, i used to code in DARK GDK like 3 years ago i think, but then i began using PHP and i let the dark gdk aside.

1 year ago i found allegro, a 2D Game library based on OpenGL, and i made a little engine with basic features to a platform game.

a few days ago i begin question myself: "why won't i use DarkGDK since it has more to offer than allegro?"
So i dicided to migrate the engine coding to darkgdk, and i made it in less than 1 day because it was just some C&P with some syntax changes.

Ok now i got my project setup 100% but when i try to go in-game the game is just too slow, i set the display of the fps ON and it's on 1~4 per second...

Not sure why..

Anyway, since it's an engine it has some classes and other functions and since i will release the Open source when its finished i uploaded all project into mediafire.

If you guys could help me with the fps errors it would be great.

The fps issue is on this part of the code:



LOOP
{
if(state == 1)//gamestates
{
//blabalbla
}
if(state == 2)//actual gameplay
{
dbPasteImage(BACKGROUND_IMAGE, 0, 0);
map.Draw();
player.Update();
player.Draw();
enemy.Update(map.getLevel());
enemy.Draw(map.getLevel());
//collision.Update(player, enemy, map);
//camera.Update(player.x, 0);
//camera.Draw();
UpdateBullet(bullets, NUM_BULLETS, enemy, map);
DrawBullet(bullets, NUM_BULLETS);

if(shoot_timer > 0)
{
shoot_timer = shoot_timer - 1;
}
if(dbKeyState(DIK_SPACE) && shoot_timer < 1)
{
FireBullet(bullets, NUM_BULLETS, player);
shoot_timer = 30;
}

FRAME_RATE = dbScreenFPS();
strcpy(SCREEN_FPS,"Frame Rate: ");
strcat(SCREEN_FPS,dbStr(FRAME_RATE));
dbText(0,120,SCREEN_FPS);

}
}

its on the state==2 that the fps is really limited.. Thanks in advance

Here's the download: http://www.mediafire.com/?as8n5iiw87616nu

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)

Attachments

Login to view attachments
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 9th Jun 2012 23:33 Edited at: 9th Jun 2012 23:33
It may be because you are using images which are slow, try using sprites. It is hard to tell as we have no idea what the functions do that are in state == 2.
haliop
User Banned
Posted: 10th Jun 2012 01:31
i tried to download but it dosent download at all
can you upload it here?
you can attach a file to your post.
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 10th Jun 2012 11:34
I uploaded to the post.

@Mr Bigglesworth
I tried using sprites instead, but same thing.

I dont know if it helps, but in allegro there is no support for movement or anything, just graphics, so the movement in this project is based on the other that is make a dbSprite in x and y that are changed for keypress's, but i dont think thats the problem because i didnt draw the player it...

Just map, enemy, background

Thanks for the replies and i hope you can help me :/

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 10th Jun 2012 13:06
You know, map.Draw(); method is causing the performance drop...

vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 10th Jun 2012 13:11 Edited at: 10th Jun 2012 13:17
Hum... should i make a system to only draw once?

EDIT
It worked, i draw the map one time now and its running 60 fps now.

Thanks a lot

But if i want to make a screen scroll doesnt the map need to be draw all time?

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)
Mister Fuzzy
13
Years of Service
User Offline
Joined: 27th Feb 2011
Location: XNA
Posted: 10th Jun 2012 19:23 Edited at: 10th Jun 2012 19:25
Quote: "But if i want to make a screen scroll doesnt the map need to be draw all time?"
Yes, you do unless you are using Sprites to represent the tiles. If you're using sprites, you can just move them around.

The problem with your Draw function is probably that your map is larger than the screen area, thus you are drawing tiles that are not even supposed to be visible. If you throw in a checker for detecting whether a certain tile will be in the play area before drawing it, you should see a performance boost while maintaining your original code layout.

ALIEN(S)!!!!!!!!1!! (and sausages)
vitinho444
14
Years of Service
User Offline
Joined: 12th Oct 2010
Location:
Posted: 10th Jun 2012 22:05
Wow thanks a lot mister fuzzy

I will try to do that

C++ Medium 3.5/5
www.oryzhon.com <-- My company's website (W.I.P)

Login to post a reply

Server time is: 2024-11-19 00:30:29
Your offset time is: 2024-11-19 00:30:29