Graphics questions

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
rvj
Prole
Posts: 15
Joined: Fri Feb 10, 2012 5:55 pm

Graphics questions

Post by rvj »

Hey guys! I've been reading for a couple of months, this is my first post. I've looked around for answers but these are rather specific questions.

My game is a top down space shooter/sim. Kind of like a semi-realistic asteroids-- instead of moving around the screen, you can fly around a huge battlefield scattered with asteroids, fighting other space ships. My FPS goes from 57-60 (hardware reasons I guess) on Ubuntu and Windows, but then slows down to 30 or 40 sometimes.

Right now I probably have under 10 objects at the moment, each checked by a collision detector. If I had a couple missiles with smoke trails (from a particle emitter) the frame rate slips down. I'd ideally like to have a hundred or so objects on the screen, and a hundred or so more off the screen (being updated but not drawn). I'd also love it if I could have my smoke trails stay in the world indefinitely, but that destroys my FPS.

1. I scale my whole world by .3 at 1024x768, the default resolution. Then for other resolutions, I scale as required. So I have sprites around 128x128 or 256x256 or whatever, then scale them. Is that alright, or not good for speed?

2. My background needs to cover the whole world. I use parallax on it, and it's scaled, but I used a texture that's 1024x768. Is that normal practice?

3. I use a fair number of shapes.. for the HUD, mostly. I probably draw around 200 small lines, a few rectangles, and some circles.. and I'm just starting with the hud. I read somewhere that shapes are slow with Love? Should I avoid them and use images in their place? I also have a boundary circle. It's drawn every frame, but only seen when you get close to it (ie. when it's on the screen). It's a huge circle is that bad practice?

4. I use scale to animate explosions.. so I've got a simple sprite that I blend with 'additive' and grow and shrink over a couple of seconds. Is that pretty normal? It slows down like crazy on Windows for some reason (I scale it up to about the size of the screen..)

5. Does anyone have any resources on 2D graphics effects? I'm kind of making things up as I go...

Thanks so much for any help or extra tips. I hope to be a contributor on this forum in the future. The great community around this engine was a huge draw for me to start using it!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Graphics questions

Post by Robin »

Welcome!

We can help you better if you attach a .love. Your questions are hard to answer without seeing your current implementation.

EDIT: lemme correct my own posts, bartbes! :x
Last edited by bartbes on Fri Feb 10, 2012 8:31 pm, edited 1 time in total.
Reason: Making up for robin's BBCode incompetence
Help us help you: attach a .love.
rvj
Prole
Posts: 15
Joined: Fri Feb 10, 2012 5:55 pm

Re: Graphics questions

Post by rvj »

I was avoiding posting the source. I'm using a few images that are more.. placeholders, as I didn't really make myself. I can point out the parts in question. The scale stuff is mostly in Camera.lua. The explosion in quesiton is ExplosionB.lua. The shapes are mostly HUD.lua.
(edit) Oh yeah, WASD to move, space to shoot, m for missile.

Thanks!
Attachments
fight.1.love
(3.3 MiB) Downloaded 168 times
rvj
Prole
Posts: 15
Joined: Fri Feb 10, 2012 5:55 pm

Re: Graphics questions

Post by rvj »

OK so doing some work on my own I've answered my third question: rectangles appear to take a similar time to draw as images. Overall in my un-scientific tests I'd say the rectangles were faster.

I pretty much just drew a few thousand rectangles on the screen, measured how long it took, then took the average of that over the course of a few frames. Then I did the same for the images. There were also a few supporting calls for each (setViewPort for example for the images, and setColor for the rectangles).
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Graphics questions

Post by Jasoco »

We don't care about placeholders. We're not going to turn you in for anything.
rvj
Prole
Posts: 15
Joined: Fri Feb 10, 2012 5:55 pm

Re: Graphics questions

Post by rvj »

Hah good. Well the source is above. I'm open to suggestions. The AI is really tough for me. I made a similar project a few years ago in C++/OGL. I got about as far as I am now, but gave up last time because the AI held me back for so long.

My concerns right now are about the performance. I can't keep adding features and fixing the AI until I can get everything to look smooth.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Graphics questions

Post by kikito »

I gave a (very quick) look at your code and I have the feeling that you are making too many zoom in/zoom out transformations.
  • Your camera draws stuff to an internal buffer, which is then drawn on the screen.
  • For each object drawn to the buffer, you do a love.graphics.push, a love.graphics.translate, and a love.graphics.pop (twice when hitboxes are turned on)
  • The background itself also requires a push, translate, scale, translate, etc...
I think that is making too many transformations and modifications.

Try drawing directly to the screen instead of using framebuffers. Try making a single push/translate/scale/pop call for all objects (ok, maybe a separate one for the background).

This might not be the key reason, but it should help.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 16 guests