Rotate Monkey app by 90 degrees?

Monkey Forums/Monkey Programming/Rotate Monkey app by 90 degrees?

Leon Brown(Posted 2014) [#1]
Does anyone know how to rotate an app from within Monkey by 90 degrees? It would be great to have something like AutoScale that can be called up once and will adjust all input detection as well as showing the app rotated.


Goodlookinguy(Posted 2014) [#2]
http://www.monkey-x.com/docs/html/Modules_mojo.graphics.html#Rotate
Rotate(90)



DruggedBunny(Posted 2014) [#3]
This might possibly help with rotated input detection:

http://www.monkey-x.com/Community/posts.php?topic=1992


Leon Brown(Posted 2014) [#4]
Thanks everyone. I've solved it with this example:

http://www.monkey-x.com/Community/posts.php?topic=8553

The rotate was causing distortion originally, but is now solved after adding the translate command. I've only partially tested the input, so I'll test this properly tomorrow.


Playniax(Posted 2014) [#5]
The playfield system of Ignition X can do all of this. In this demo the screen rotates and the mouse/touch input rotates with it. Even scrolling and zooming is supported.


Leon Brown(Posted 2014) [#6]
I took a look at the coordinates example, but still can't get the coordinates working properly. I put this in the OnUpdate method:

Self.mouse_lastX = AutoScale.dTouchX(0)
Self.mouse_lastY = AutoScale.dTouchY(0)
		
PushMatrix()
	'Apply the last saved mapMatrix, that is, all rotations, scalings and translations applied since the program started
	Transform( _worldMatrix[0], _worldMatrix[1], _worldMatrix[2], _worldMatrix[3], _worldMatrix[4], _worldMatrix[5] )

	'Work out what coordinate the mouse is pointing at by doing the matrix transformation backwards.
	Local coords:Float[] = InvTransform( [ Self.mouse_lastX, Self.mouse_lastY ] )
	Self.mouse_lastX = Self._worldMatrix[0]*Self.mouse_lastX + Self._worldMatrix[1]*Self.mouse_lastY + Self._worldMatrix[4]
	Self.mouse_lastY = Self._worldMatrix[2]*Self.mouse_lastX + Self._worldMatrix[3]*Self.mouse_lastY + Self._worldMatrix[5]
PopMatrix()


The values of Self.mouse_lastX and Self.mouse_lastY are what need to be converted to the new coordinates for where the screen has been rotated 90 degrees. You'll also see in the code that I'm using that I'm using AutoScale to create a virtual resolution - I'm not sure if that affects anything regarding the coordinates.


Goodlookinguy(Posted 2014) [#7]
I feel like you don't understand matrices and vectors. If this is the case, please go and take a crash coarse on them before proceeding with what you're trying to do. It's not hard to do what you're asking, but not learning about matrices and vectors and having answers given to you is a great disservice to yourself.


Leon Brown(Posted 2014) [#8]
I do indeed understand about matrices and vectors, so this isn't a problem. The code I have uses a matrix system for collision detection, but I am unsure how to set this up for the screen rotation. After spending all day on the issue, I thought someone on here could help.


Goodlookinguy(Posted 2014) [#9]
Several people on here don't know about matrices and vectors and then ask questions while using matrices even though they don't really understand them. So I just wanted to make sure.



Edit: I don't know what you were trying to do with your code if I'm being honest. It really gives the appearance of you not understanding matrix math.