Drawing

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
Zeggy
Prole
Posts: 13
Joined: Sun Nov 30, 2008 4:38 pm

Drawing

Post 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
User avatar
cag
Citizen
Posts: 65
Joined: Sun Jun 29, 2008 5:09 am

Re: Drawing

Post 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.
Zeggy
Prole
Posts: 13
Joined: Sun Nov 30, 2008 4:38 pm

Re: Drawing

Post 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
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Drawing

Post 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 4304 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.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
Zeggy
Prole
Posts: 13
Joined: Sun Nov 30, 2008 4:38 pm

Re: Drawing

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests