Scrap Mechanic

Scrap Mechanic

Not enough ratings
Screen Module
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
123.995 KB
11 May, 2021 @ 11:25pm
30 Dec, 2021 @ 6:34am
5 Change Notes ( view )

Subscribe to download
Screen Module

In 1 collection by wingcomstriker405
My Mods
17 items
Description
This mod is an extention module of the Programmable Processor. It allows to paint on a 96x54 pixel display. Currently it supports uppercase text, drawing and filling ovals and rectagles. Please keep in mind that it is still work in progress and
things might change later in development.
In case somebody wants to know the current technical interface to do stuff feel free to get in touch :D
If you encounter any bugs let me know :)
Have fun!

SMPL API
getScreens drawString this text x y color drawRect this x y w h color drawOval this x y w h color fillRect this x y w h color fillOval this x y w h color getResolution this getSize this setResolution this width height setSize this width height equal this other unequal this other with - this, other being screen objects - x, y, w, h being numbers - text being a string - color being a tuple of r, g, b

HLL API
get_screens parameters: [ ] description: returns a list of all screens that the computer is connected to. set_screen_resolution parameters: [ screen, width, height ] description: sets the amount of pixels of the screen. be careful using this function because it will recreate all pixels when calling the function and can potentially cause lag. the default resolution is 96x54. set_screen_size parameters: [ screen, width, height ] description: scales the screen to fit into the desired width and height. the resolution / ratio of the screen stays the same -> the screen might get distorted. draw_str parameters: [ screen, text, x, y, color ] description: draws the string in the specified color on the screen with the left upper corner of the string as a reference. it currently only knows uppercase input text which i will fix. draw and fill parameters: [ screen, shape, x, y, width, height, color] description: draws a shape in the desired color on the screen. it can draw rectangles ('rectangle' as shape parameter) where x, y specifies the left upper corner and w, h specify the width and height of the rectangle. it also draws ovals ('oval' as shape parameter) in which cases x, y is the center point and w, h specify the dimensions of the oval.

The color parameter is a list with 3 numbers from 0.0 to 1.0.

SMPL Example
import Screen import Camera import Math II.setClockSpeed(10000) width = 16 * 2 height = 9 * 2 screen = Screen.getScreens()[0] screen.setResolution(width, height) screen.setSize(16 * 3, 9 * 3) range = 100 camera = Camera.getCameras()[0] camera.setCastsPerTick(1000) camera.setResolution(width, height) camera.setFov(160, 90) camera.setRange(range) camera.setMode('ALL') (screenWidth, screenHeight) = screen.getResolution() screen.fillRect(0, 0, screenWidth, screenHeight, (0, 0, 0)) while true camera.capture() while camera.isCapturing() II.interrupt() end for y = 0, y < height, y += 1 for x = 0, x < width, x += 1 entry = camera.getData(x, y) color = entry[3] if entry[2] == 'terrainSurfaceSand' color = (1, 1, 0) end if entry[0] v = 1.0 - entry[1] / range (r, g, b) = color screen.fillRect(width - x - 1, y, 1, 1, (r * v, g * v, b * v)) else screen.fillRect(width - x - 1, y, 1, 1, (0.3, 0.3, 1)) end end end end
16 Comments
NukeMan64 7 Jun, 2022 @ 12:12pm 
Would be cool to add WebGL support.
wingcomstriker405  [author] 14 Jan, 2022 @ 11:45am 
Would be a cool project for sure. But I'd say it would be better (performance wise) to do it as a module for the language
NukeMan64 14 Jan, 2022 @ 11:30am 
I could try to port my game engine to here. Similar to Unity, but it's in TypeScript and only supports retro 2D style
wingcomstriker405  [author] 12 Nov, 2021 @ 1:36pm 
Im not sure what you mean. I wanted to make a better / usable screen for some time :D
NukeMan64 12 Nov, 2021 @ 12:20pm 
Striker, I thought you didn't want something like this! Now I can make a game engine!
wingcomstriker405  [author] 11 Sep, 2021 @ 1:33pm 
you need to write a program on the computer to draw on the screen. its basically a canvas that you can draw / write on
Carson_Coder 11 Sep, 2021 @ 11:03am 
the processer setup computer and keyboard
wingcomstriker405  [author] 11 Sep, 2021 @ 9:54am 
what keyboard do you mean?
Carson_Coder 11 Sep, 2021 @ 9:51am 
how do i use this with the keyboard
wingcomstriker405  [author] 1 Jul, 2021 @ 5:45am 
Glad you like it :) i hope i can improve the usability soon