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

shake screen API function #33

Closed
nesbox opened this issue Feb 1, 2017 · 2 comments
Closed

shake screen API function #33

nesbox opened this issue Feb 1, 2017 · 2 comments
Assignees
Labels
API Issues related to TIC80 API enhancement Improvement of existing feature or adding something new
Milestone

Comments

@nesbox
Copy link
Owner

nesbox commented Feb 1, 2017

add a function to draw entire screen buffer with XY offset
shake [x y]
the offset will reset every frame to 0:0 if you won't call the shake api

@nesbox nesbox self-assigned this Feb 1, 2017
@nesbox nesbox added the enhancement Improvement of existing feature or adding something new label Feb 1, 2017
@nesbox nesbox added this to the 0.17.0 milestone Feb 1, 2017
@nesbox nesbox mentioned this issue Feb 1, 2017
@nesbox nesbox added the API Issues related to TIC80 API label Feb 1, 2017
@nesbox
Copy link
Owner Author

nesbox commented Feb 2, 2017

I decided not to add 'shake' API func and added XY variables to the RAM by address 0x3FF9

shake

-- 'shake screen demo' demo

shake=0
d=4

function TIC()

	if btnp()~=0 then shake=30 end

	if shake>0 then
		poke(0x3FF9,math.random(-d,d))
		poke(0x3FF9+1,math.random(-d,d))
		shake=shake-1
		
		if shake==0 then memset(0x3FF9,0,2) end
	end

	cls(12)
	print("PRESS ANY KEY TO SHAKE THE SCREEN!",24,64)
end

so, works in .17

@nesbox nesbox closed this as completed Feb 2, 2017
@AlecTroemel
Copy link
Contributor

I know this is really old, but in case anyone wants to do this in javascript, its Math.random works a little bit differently. To get a random number between min and max (what lua's random does), you could do something like

var min = -d, max = d
Math.random() * (max - min) + min

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues related to TIC80 API enhancement Improvement of existing feature or adding something new
Projects
None yet
Development

No branches or pull requests

2 participants