Jump to content

BMD/Graphics for drawing every frame - which one is faster?


Raicuparta
 Share

Recommended Posts

Here is my game: Curvatron.

In that version (a bit outdated now) the snake's tail is drawn using a Bitmap Data. Every frame, it draws a sprite (small circle) under the snake's head, and erases the end of the tail with a clearRect. This is ugly but it was the fastest method I could find at the time, for mobile. 

 

I have been trying to find other ways to do this so that I can have a prettier version on PC, but I'm not sure which one is the best. I tried:

  1. Using Graphics, drawing the entire body with a thick line. The entire line is erased and then redrawn every frame.
  2. Same thing as 1, but with Bitmap Data.
  3. Using Bitmap Data, drawing small circles (not sprites) for each body point, for the entire body. The entire thing is erased with a clearRect every frame and then redrawn.

Which one of these approaches is the best? Should I just stick to the original one?

 

Another question: is there much of a performance difference between using a small sprite (16*16) for drawing in the BMD and drawing a circle with the same dimensions?

Link to comment
Share on other sites

  • 2 months later...

Did you find out the answer to your question? I'd be interested to see the results of any profiling you have done.

 

Also, nice game!

Using method 2 right now. Never really got any help on this, had to just test a bunch of different ways. There are a lot of drawbacks to doing it this way, but it's the only way that doesn't completely butcher performance.

Link to comment
Share on other sites

Oh, thanks. You can also look it up on the Android Play Store or the iOS App Store, it's free.

 

 

You did a very good job. The only small improvement I have is the edge of lines have a tiny, and I mean tiny bit of pixelation going on.  

 

e0a218798a5b6f109266355c4d3aebd6.png

 

See how the edges are not quite as smooth? Maybe this is only noticeable on my big 25 inch monitor :) But, it's still fun as hell and you did a great job.  Another improvement (not sure if it's possible) but to increase the curvature. It seems like the curvatures are fixed at certain angles. Maybe allow for a more free curvy approach if you will. (If that makes sense)

 

I checked my dev console tab and didn't see the multiplayer mode is connected with node or the ws module. I think you should add that, playing with another person via websockets would be awesome.

Link to comment
Share on other sites

I am working on a new version of the game to publish in Steam. The new version looks much better and you won't notice any aliasing on resolutions up to 1080p! That actually is relevant to this thread, as if I remember correctly it only happens when I try to draw lots of sprites on the BMD.

And about the multiplayer, I'm very interested in implementing online multiplayer in the future, but there's still a lot to be done before I even start looking into that.

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...