Jump to content

Expanding the screen


7 replies to this topic

#1 pofferman

  • Members
  • 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)


Edited by pofferman, 07 February 2019 - 02:45 PM.

#2 Lupus590

  • Members
  • 1,998 posts
  • LocationUK

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.

#3 pofferman

  • Members
  • 37 posts

Posted 07 February 2019 - 07:15 PM

So it's not possible with the native term API, with a bit of hacking?

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited 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.write("Hello, World")

#5 pofferman

  • Members
  • 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 :/

#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 08 February 2019 - 12:18 AM


What value is there to shifting the arbitrarily defined values for minimum and maximum coordinates?

#7 pofferman

  • Members
  • 37 posts

Posted 16 February 2019 - 02:55 PM

It would make creating a coordinate system much easier.

#8 Purple

  • Members
  • 99 posts
  • LocationAlone 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

And than instead of:
Draw(x, y)
you do:

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 by Purple, 02 March 2019 - 06:08 PM.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users