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

drawing outside _draw in fullscreen mode #9

Open
3 tasks
pancelor opened this issue Mar 30, 2024 · 5 comments
Open
3 tasks

drawing outside _draw in fullscreen mode #9

pancelor opened this issue Mar 30, 2024 · 5 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@pancelor
Copy link
Owner

pancelor commented Mar 30, 2024

cart authors must do all drawing inside _draw -- don't do any during _update. if you do, p8x8's fullscreen mode will break

todo:

  • figure out why exactly this is true
  • see if you can make it not required anymore - tried set_draw_target(p8canvas) early but no dice. docs are sparse
  • add docs - "all drawing must happen inside _draw or functions called by _draw. if you draw during _update, fullscreen mode will look wrong"

notes:

cherrybomb and #pony9k_2_0 both have issues with fullscreen mode -- I think cherrybomb probably uses a while ... flip() end fade-in loop, which I suspect is the issue. (I didn't think picotron could even handle those style of loops! maybe just not carts that have no _draw at all?)

I tried adding set_draw_target(fakecanvas) to the end of the fullscreen draw in pony9k_2_0 but it made things worse; very strange (and earlier on I added local fakecanvas = userdata("u8",128,128)

@arrowonionbelly
Copy link

hoi! So, drawing things outside of draw, how do I fix my game if I have different draw functions? Instead of _ENV would calling a function as a variable (like _drw=draw_start and then function _draw() _drw() ?)

@pancelor
Copy link
Owner Author

pancelor commented Mar 30, 2024

Using _ENV is fine, the problem is calling any draw functions inside _init or _update. I just took a closer look at your cart; there's a cls() in startscrn() and a draw_start() inside update_start() -- remove them and your fullscreen border works fine!

edit for clarity: comment out draw_start in p8code/2.lua:

function update_start()
	-- draw_start()
	
	if btnreleased

@pancelor pancelor added documentation Improvements or additions to documentation bug Something isn't working labels Mar 30, 2024
@arrowonionbelly
Copy link

arrowonionbelly commented Apr 1, 2024

ok so I took a look at the functions that ARE working, and what's interesting is in tab 1, I have functions like drwoutline(myspr), drwmyspr(), and grid() and those functions work perfectly fine even if they have things like spr( or line( which I thought would also be draw functions, correct me if I'm wrong

EDIT:
Is the issue only if they're being called in init or update?

@arrowonionbelly
Copy link

NEVERMIND I GOT IT TO WORK!!!! AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
I took the steps you recommended, changed my rnd"x" to rnd(x) and then stuck my fullscreen graphics in a single sprite!!! this is amazing thank you so much for making this tool!!!!

@pancelor
Copy link
Owner Author

pancelor commented Apr 1, 2024

glad to hear it!! and thanks for the tip about rnd -- I didn't realize that had changed in picotron.

ah, I think we're miscommunicating over the word "inside" -- grid() is fine, it's being called "inside" draw. every line of code that runs is running "inside" of either _init, _update, or _draw. your _draw() calls draw_game() (via _ENV) which calls grid() which calls line(), and this call to line() is happening "inside" _draw, so it's fine

A different example:

function do_a()  do_b()  end
function do_b()  do_c()  end
function do_c()  spr(0,24,24)  end

function _update()
  do_a() -- this line calls `spr`, which is a problem
end
function _draw()
  do_a() -- this line calls `spr`, and that's fine
end

as to your other question about keeping up with p8x8 updates, I haven't updated the docs yet but I've sketched an outline here

I'm happy the tool's working for you now! best of luck finishing the game :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants