Page 1 of 1

Drawing

Posted: Sun Jan 25, 2009 2:24 pm
by Zeggy
Hi,
I'm making a game, and it basically consists of the player controlling a circle shape.

As the circle shape moves around, it leaves a trail of where it's been since it started moving. It's not scrolling or anything, just on the one screen that is visible from beginning to end.

How can I draw this trail? The draw function seems to 'erase' the screen each time, so it only draws the current position of the circle.

I'm guessing that I need to find some way of 'storing' the trail (by co-ordinates?) and then repaint them every frame. How can I store this trail then?

But then if I do that, wouldn't the game become very slow, having to draw so much, after having moved all over the screen?

Is there way to not have the draw function wipe the screen, and instead just 'add' the current position o the circle instead? That seems like it would be a lot easier and faster.

Thanks! :D

Re: Drawing

Posted: Sun Jan 25, 2009 5:05 pm
by cag
short answer: not feasible with simple code. if you're ambitious, you might try to implement polygon union and use that to blast a single shape on to the screen?

long answer: love is built off of hardware-accelerated texture blasting. traditionally, in 2d games, you would accomplish this by drawing to a non-screen-buffer bitmap and blast that to the screen, but because we can't blast textures on top of textures (not without some crazy high computational cost, anyways), we're stuck with drawing to the "screen buffer" and displaying the "buffer" (actually, we place things in the 3d scene and render the scene).

I don't see why you would want to do this, anyways. for the most part, maybe barring blood effects, you would never need to keep drawing something's entire history in a game, and even then, blood is probably better kept stored in a state.

Re: Drawing

Posted: Sun Jan 25, 2009 5:33 pm
by Zeggy
Um, I'm making a casual game where you are basically a paint brush, and you 'paint the screen'.

And the whole point of the game is to paint as much as you can :P

So... that's why this is very important for the game.

I've sort of come up with a solution, it's just an array that I add co-ordinates to every frame. Then I just draw the entire array of past co-ordinates onto the screen. But I really don't think that's the way it should be done because the arrays will become huge. :(

How would I go about coding a polygon union?

Thanks :D

Re: Drawing

Posted: Mon Jan 26, 2009 10:42 am
by qubodup
Zeggy wrote:How would I go about coding a polygon union?
There's this problem with polygons in LOVE.
pproblem.png
pproblem.png (5.54 KiB) Viewed 4305 times
Um.. if the game is keyboard-controlled, then only 8 movement sorts are possible. In that case you could use rectangles (rotated for diagonal movement) plus circle (at start, current location and at each turn) to draw the path.

Re: Drawing

Posted: Mon Jan 26, 2009 11:50 am
by Zeggy
qubodup wrote:Um.. if the game is keyboard-controlled, then only 8 movement sorts are possible.
Oh, um, actually, I coded a 360-degree movement in by using left/right to rotate 5 radians at a time. Those are the only two controls, the player object moves forward by itself, in a straight line if the user doesn't do anything. And left/right to change direction (counter)clockwise.