37 posts
Posted 07 February 2019 - 02:42 PM
I'm playing around with Computercraft, and so far I have created a player "Box", that moves around the screen. I have also made a camera, so that i can shift the player, without changing the player position.I noticed, that you can't go under (1;1) with term.setCursorPos(), is there a hack to bypass this?I'm using a window as the camera module, and I'm using the window.reposition() function.The reason, why I am able to go beyond the native max resolution is, that i have specified the window with these paramaters:
local renderWindow = window.create(term.current(), -xT*2, -yT*2, xT*2, yT*2, false)
https://youtu.be/GY5KgvdRYMc
Edited on 07 February 2019 - 01:45 PM
2427 posts
Location
UK
Posted 07 February 2019 - 05:16 PM
Make your own window like object which allows for drawing out of bounds. You may want to look at the source code of the window API.
37 posts
Posted 07 February 2019 - 07:15 PM
So it's not possible with the native term API, with a bit of hacking?
3057 posts
Location
United States of America
Posted 07 February 2019 - 08:27 PM
You *can* set the cursor position offscreen. It just won't display anything you draw offscreen. Easy test:
term.setCursorPos(-1,1)
term.write("Hello, World")
37 posts
Posted 07 February 2019 - 08:35 PM
And that is the whole point. To be able to go below the minimum coordinates of 1,1.
I'll have to figure something out then :/
3057 posts
Location
United States of America
Posted 08 February 2019 - 12:18 AM
Why?
What value is there to shifting the arbitrarily defined values for minimum and maximum coordinates?
37 posts
Posted 16 February 2019 - 02:55 PM
It would make creating a coordinate system much easier.
102 posts
Location
Alone in the dark, looking at the pretty lights with dreams of things I can not have.
Posted 02 March 2019 - 06:06 PM
Just create a custom function that takes two parameters (x and y) and returns two values newX and newY such that the center of your screen is 0, 0. And call that every time you are sending your game coordinates to the screen.
Pseudo code:
function gameToScreen(x, y)
newX = x + screenWidth / 2
newY = y + screenheight / 2
return newX, newY
end
And than instead of:
Draw(x, y)
you do:
Draw(gameToScreen())
That way your game logic can work on a coordinate system that is separate from the screen one. And later when you decide to separate the two completely as you might well do you have a ready made function to do it with.
Edited on 02 March 2019 - 05:08 PM