dragongem (beta)

Show off your games, demos and other (playable) creations.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

dragongem (beta)

Post by farvardin »

I've begun to make a little game. I wanted to work on it and present something nice, but I'm afraid there are some problems with this game, it's way too slow, after a few seconds my cpu go to 100% and after quitting the game (q or closing the window), my system is very unresponsive.

I've tried to isolated several parts but I can't find what is causing the slowness.

It would be really cool to have a screen which could monitor every process in love and track down which one is the most CPU heavy so we could optimise games more easily.

The rules (taken from the DOS game dragon sphere) :
There are 4 different colors in this game: red, yellow, green and purple.
In a pouch lie 12 gems of each color. You can get point by having good guesses.

The winner is the first to reach 16.

You have to choose one color, and compare it with the gem which will be taken out of this bag:

- if you choose red, you get 1 point and can play again if the gem is red, yellow or green. If the gem is purple, end of your turn.

- if you choose yellow, you get 2 points and can play again if the gem is yellow or green. If the gem is red or purple, end of your turn.

- if you choose green, you get 5 points and can play again if the gem is green. If the gem is not green, end of your turn.

- if you choose purple, you get 12 points and can play again if the gem is purple. If the gem is not purple, your opponent get 2 points (but can't win even if the score is 16), and it's the end of your turn.

It's not yet possible to play against computer or win the game...
Last edited by farvardin on Sun Jan 25, 2009 5:12 pm, edited 3 times in total.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: dragongem (beta): why is it so sloooow ?

Post by osuf oboys »

farvardin wrote:I've begun to make a little game. I wanted to work on it and present something nice, but I'm afraid there are some problems with this game, it's way too slow, after a few seconds my cpu go to 100% and after quitting the game (q or closing the window), my system is very unresponsive.
I started with Lua yesterday so I might be off. The problem is that for each call that is made to draw, you load two new font files - at 100+ FPS, this uses up memory fairly quickly. It seems that either you need to destroy() an object before the gabage collector picks it up, or the GC is incomplete. The solution is either to destroy the fonts after you have used them / before you create new ones, or to simply create the fonts outside the loop.
farvardin wrote: It would be really cool to have a screen which could monitor every process in love and track down which one is the most CPU heavy so we could optimise games more easily.
You could do this with the help of a table and the timer. If you implement it using hooks, it might even be convenient.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: dragongem (beta): why is it so sloooow ?

Post by bartbes »

As I'm always somewhat interested in performance, I read the code, added an FPS display and put every create function in the load callback, it boosted the FPS from 28 to 60 (vsync) on my pc. I guess this answers both your question and mine (which was if it would really have a big impact).
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

Re: dragongem (beta): why is it so sloooow ?

Post by farvardin »

you're right osuf oboys! I didn't think to the fonts! I've commented the font calls, and made the default font outside the draw function, and it's working fine now. Thank you very much.

I didn't really understand your answer bartbes :(

I'll remove the game file now, I'll upload a new one when the game will be finished!
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: dragongem (beta): why is it so sloooow ?

Post by bartbes »

It wasn't an answer, I just wanted to say I tried it and had good results, satisfying my desire to know if loading is slow.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: dragongem (beta): why is it so sloooow ? (solved)

Post by rude »

When a font loads, it creates 255 textures and sends them to the GPU. You don't want to do that every frame. Of course, we've been through this before, so I guess I should make a wiki page or something about it.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

Re: dragongem (beta)

Post by farvardin »

Here is a working version of Dragon Gems.

It's a very simple game and needs improvement (real player vs computer mode, network game, maybe more strategy if possible) but I hope you'll like it anyway.

I wanted to make animation when a gem was selected, but I didn't manage to make it move and stop after a few steps.
Attachments
dragongem.love
(old, obsolete version, see below...)
(275.82 KiB) Downloaded 294 times
Last edited by farvardin on Sun Jan 25, 2009 9:14 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: dragongem (beta)

Post by bartbes »

Though it's not really the type of game I enjoy playing most, it's good enough for some random killing of time. However the graphics are GREAT! I was surprised however to find that all text's are actually images instead of text, as I really think it should be a font. And let's not forget about the help screen!

@farvardin: although I'm mostly talking about the graphics, I actually DO like the game.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

Re: dragongem (beta)

Post by farvardin »

thank you for your comment bartbes!

about the fonts, only the gothics / medieval fonts are pictures, others are regular fonts (I don't know how it looks on other platforms, windows, mac os x, because the texts are supposed to fit exactly the area)

I've made an update to the game, now the "computer turn" is selected randomly, and the button for playing for the computer is highlighted when it's the computer's turn. Some future options could include a timer for automatically playing the computer's turn...
and I'd really like to try networking... maybe with Lube? Do you think it could easily be done with it?

Image
Attachments
dragongems.love
(281.98 KiB) Downloaded 235 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: dragongem (beta)

Post by bartbes »

Well, it should be possible, but I don't know exactly how you want to implement it. You can always ask me to help you or implement a feature. ^^
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 7 guests