Looking for different solutions

BlitzMax Forums/BlitzMax Programming/Looking for different solutions

Xip(Posted 2008) [#1]
I have been working on a game for a over a week now(an Crayon clone), and i so far evrything is working great.

however, i have finnaly arived to a part im not entierly sure how i will solve... i have a few ideas, but but thay all have problems wich might not work very good in this game (performance wise).

I'm currently only drawing the vertexes used by the chipmunk engine, however... i have always wanted to create some sort of realistic crayon brush or other type of pen or water color, now... this couses a few problems, becus it is not only one background surface im drawing on.

now, if we where only drawing on a static background, this would be very simple to do... however, things are a bit different now :S

Oky, so here are the problems.

1. Since we dont know the total width+height of the shape we are drawing until we have finnished drawing with the brush, it is hard to create an image, also... creating on the fly, half the screen in size(for example) seems slow(?) and will hit the framerate.

2. even if i break things down to small blocks, we dont know how many we need to allocate in advance. and even if i where to pre-load tons of blocks to be used later, then we would have a limit in the number of shapes until we need to create them on the fly again, and then we would have a slow-down when we hit that limit.

im not sure if im explaning my self very good or not :S

to summon up, we dont know how many Images to allocate in advance, we dont know the finnal width and height of our shape(so we cant create one big image when we are finnished, and if we do, that might be to slow for realtime).
we are creating tons of shapes, and it dont seem good for the performance to create a new image on the fly for evry line drawn ether.

however i turn this around, i seem to get to the same problems... so, does any one have an idea how thay would solve this?

I relly Relly dont want to draw a simple line from dot to dot, a custom brush would be much nicer for a game like this.

[edit2] im leaning towards creating tons of small images in a list, and access them when i draw outside my current grid of images

but if any one knows a bether solution, im all ears. :)


nawi(Posted 2008) [#2]
Are you making a Crayon physics game?

When a shape is drawn or loaded for the first time, then just draw it and save it as one image (or, maybe 2-3 slightly different versions that you draw to create a nice effect). When a user is drawing the shape then you just update a single picture. Create a couple brush pictures that you draw from.


Xip(Posted 2008) [#3]
yeas Nawi, im creating a crayon physics game :)

I'm not sure i anderstand what you mean however... you are a bit vage;)

"When a user is drawing the shape then you just update a single picture"

"then just draw it and save it as one image"

[edit]

i think you will have to explain what you mean by 'just draw it', if you read my first post you will see that this is the problem in the first place.

draw it on what? how? the problem is to find/create a good surface to draw on.

The idea was to use pixel per pixel manipulation for best possible and realistic crayon brush.


feel free to elabrate :)


Xip(Posted 2008) [#4]
oky, an friend read this thread, and gave me his opinion on what he thought you meant... assuming this is the case.

you want to createe one huge background image, and then draw on it, and when finnished create a new image and copy the surface.

problem is, unless we split the background image into lots of smaller images(this is one solution ofcourse), this will be SUPER slow, writing 1 pixel per frame into a 800x600 image, gives 7-8fps on my pc.
i gues it might be a bit faster to copy area from backbuffer to image, but we still have to clear the background image each time we are finnished with a shape, and some tests i did showd a drom from 60 to 30fps while copying a 400x400 surface from backbuffer to image, even it this might work, im not happy with it... it would feel slaggysh(if that is a word?).

best solution i can see right now, would be to have a grid of images(for each shape), each time you draw it checks what grids are involved, and then create and draws on that small image, it then uses these images as the finnal product, looping trow and drawing each block when drawing our shape.

but this is tons and tons of more lines of code, not so sure its worth it.

any other ideas would be great :)


LAB[au](Posted 2008) [#5]
For your problem, I suggest single surface 3D, like particle engine are using, duplicating a "seed" over a path. That is pretty fast. 3D is faster than 2D also (in most cases doing 2D in 3D is faster than using plain 2D).

You can make 3D looking like 2D.


Xip(Posted 2008) [#6]
im not used to working with OpenGL manualy, and i am afraid i suck way to much on it, but i gues it is one solution :S


Xip(Posted 2008) [#7]
After some testing, it turns out that the small-block solution was not so performance demanding as i thought(60 fps at all time), so i will go for that one :)

tons of extra code, but it will be worth it in the end :)
well, tanx any way for the feedback