Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent clearing of the screen? #61

Open
jeffchiou opened this issue Sep 10, 2022 · 2 comments
Open

How to prevent clearing of the screen? #61

jeffchiou opened this issue Sep 10, 2022 · 2 comments

Comments

@jeffchiou
Copy link

jeffchiou commented Sep 10, 2022

For example, I want this to result in tracing a line along w's history of positions.

function draw(g::Game)
    draw(Circle(w.x, w.y, 1), colorant"gray")
end

For me it just shows the circle moving about as determined by w's update function, while I'm expecting many little circles showing w's trajectory.

It seems in certain examples you had to clear the canvas by adding clear() or fill()? But for me I see no difference.
https://docs.juliahub.com/GameZero/tTDGf/0.2.1/examples/basic2/

function draw()
    fill(current_color)
    ...

https://docs.juliahub.com/GameZero/tTDGf/0.2.1/examples/Breakout/

function draw()
    clear()
    ...

Is what I'm asking for possible? Sorry if I'm missing something obvious, I'm fairly new to Julia.

@jeffchiou
Copy link
Author

Looked in the source a bit, found that if I remove the clear here I get what I want

function mainloop(g::Game)
    ...
      # Render
      #if (debug && debugText) renderFPS(renderer,last_10_frame_times) end
        clear(g.screen)
        Base.invokelatest(g.render_function, g)
    ....

Perhaps it would be a good idea to include an option to specify whether you want to auto-clear after every frame?

@scottbigbrain
Copy link
Contributor

We could make it default to auto-clear and then allow for a flag that disables it.

function draw(g::Game)
    # auto-clears
end

function draw(g::Game, noclear=true)
    # no auto-clear
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants