Jump to content




[Emu-/Simulator] LUAComputers progress!


5 replies to this topic

#1 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 14 December 2017 - 08:22 PM

LUAComputers

(Kind of my own CC2.0 attempt)

INFO:
  • The program is currently made with Love2D, although I might consider converting to Python, C++ (is an option, but I really do not prefer it) or Java. (Python and Lua/Love2D I experienced are very simple to use so I don't really know any reason to switch to Java or even C++)
  • The window has a size of 1600x900 (to make the "pixels" of the terminal visible/big enough) and the terminal has a "size" of 102x38 (basically the double of current ComputerCraft)
  • It still uses that background/foreground drawing system, meaning that these "pixels" are rectangles with a char on top of them
  • There isn't really any functionality other than drawing pixels onto the terminal (and I guess writing too) currently, as I started programming it yesterday
  • I will try to imitate the APIs of ComputerCraft, although I am not completely sure about that yet
  • Networking is planned using UDP sockets (very basic)
Code:
GitHub

SCREENSHOTS:
Spoiler

The code for that program would be practically the same as in actual CC:
term.setCursorPos(3, 4)
term.setBackgroundColor({255, 0, 0})
term.write("Hello ")
term.setForegroundColor({0,0,255})
term.write("W")
term.setForegroundColor({0,0,0})
term.write("o")
term.setForegroundColor({255,255,255})
term.write("r")
term.setForegroundColor({0,255,0})
term.write("l")
term.setForegroundColor({255,255,0})
term.write("d")

--term.set[SOMETHING]Color currently uses a table with the pattern {rrr, ggg, bbb} but there will be a color table later on

I will gladly take suggestions from this (dead) community if there are any! :)

Also does anybody have an idea of how I could make the window be smaller, yet the pixels be still big enough to be readable? My current calculation of the width / height of a pixel is basically pixel_width = window_width / amountOfPixelsOnXAxis and pixel_height = window_height / amountOfPixelsOnYAxis.

EDIT:
To remove extra window space, the window has to be exactly 1530x874 to have the pixels as big as you can see and not have any extra useless window space.


EDIT: This version of the project is deprecated, as I remade it in Java. Take a look at post #6

Edited by Piorjade, 21 January 2018 - 04:13 PM.


#2 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 16 December 2017 - 01:25 AM

UPDATE:

Okay so basically what I changed was the whole graphics / terminal system. As you can see in the old pic I used the system that ComputerCraft 1.0 uses by drawing one character on one "pixel". The problem with that was that I couldn't create many pixels on the screen as that would make the characters way too small to be readable.
So what I decided to do instead is actually give the use the ability to manipulate "pixels" on the screen (320x180).
The thing with THAT one though is that there is no "easy" way of actually writing text onto the screen, which solution was to make an API (I renamed the old term API to gpu) called 'term' which allows us to draw characters onto the screen.
One character contains 6x6 pixels.

Now, I made 3 different function in the term API to draw characters.
Function 1:
  • Draws the raw character somewhere on the screen
  • Needs the exact coordinate given (so a coordinate with a maximum of 320|180)
Function 2:
  • Makes a grid out of the screen by dividing the dimension by 6
  • Needs the "cell"-coordinate where you want to draw the character in (e.g. cell 2|2 actually is 7|7 as exact screen coordinates)
  • Does not create room inbetween characters, making them a bit harder to read when in sentences
Function 3:
  • Makes a grid out of the screen by dividing the width by 8 and the height by 6
  • dividing by 8 instead of 6 creates room inbetween characters and gives us an integer instead of a float, making the grid fill the whole screen correctly
  • Basically the extended version of function 2
With this combination you are able to make higher resolution programs yet still be able to write onto the screen (of course the font is bigger than the old version I had, I could increase the amount of pixels, allowing us to have a smaller font but I thought that wouldn't be as "retro-like" as it is now).

Screenie of the text/font using the 3rd function and something I drew with my mouse (every line of text actually has 1 line space inbetween them, meaning that I could write something inbetween too..):
Spoiler

Edited by Piorjade, 16 December 2017 - 01:29 AM.


#3 CLNinja

  • Members
  • 191 posts

Posted 16 December 2017 - 03:32 AM

Any demos currently able to be played with? Might help for general debugging and stuff when people find issues.

#4 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 16 December 2017 - 12:05 PM

View PostCLNinja, on 16 December 2017 - 03:32 AM, said:

Any demos currently able to be played with? Might help for general debugging and stuff when people find issues.

Technically I could already upload it but there isn't anything really you can do with it, the only thing that works is the GPU api and the term api, which you can also only write text with it.

I think I should add a couple more things before I'll upload it. :)

Edited by Piorjade, 16 December 2017 - 02:27 PM.


#5 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 18 December 2017 - 06:31 PM

UPDATE:
Got the networking to finally work! (It doesn't work with 2 instances on the same pc though)

Aaaand I uploaded the code on GitHub:
https://github.com/P...de/LUAComputers
There is a short tutorial on how to "install" and how to test the networking

EDIT: This version of the project is deprecated as I remade it in Java, take a look at the post below

Edited by Piorjade, 21 January 2018 - 04:11 PM.


#6 Piorjade

  • Members
  • 244 posts
  • LocationComputer, Germany

Posted 21 January 2018 - 04:10 PM

I kinda forgot about this post, but...
I decided to rewrite this project in Java because 1. I am currently learning Java in school and that helps me get better grades and 2. practically everybody has Java so nobody has to download something just to start the program up.

What I'm using now
It's not much, but I'm using:
  • LuaJ for the Lua wrapper (I'm not experienced with it at all, but I think I get it by now)
  • libGDX for the window, graphics and audio (I first thought about LWJGL, but then I realized that it's not worth the hassle and that libGDX handles the low-level things for me)
  • Standard Java sockets for networking
NOTE: I did not try to replicate what I had already done in the Love version of LuaComputers, so the APIs' methods might be different than the ones from the old one

Here's the GitLab link to the repository, it also has some wiki pages for the APIs already

And here's a post I made on steemit about it





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users