A rendering program in lua

A spot for all things TestTube
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

A rendering program in lua

Post by robly18 »

So I've been thinking about a problem which I won't discuss right now because it's of no relevance, but how I have been trying to solve it.
So here's what happened... I made a basic rendering software. You have a dot on a screen, and you can use code to make it move around. So far I made a basic physics engine with bouncy balls.
Anyway, I just thought I'd ask for an opinion on it. It's actually the first time I've done anything like it and I'd like feedback!
http://notepad.cc/robrender1

Plug this code into this:
http://www.lua.org/cgi-bin/demo

Right now the physics are... Buggy, to say the least. But I'm working on improving them.
So, give me your opinion! How's my rendering code skills?
Convincing people that 0.9999... = 1 since 2012
A Random Player
Posts: 523
Joined: Mon Jun 03, 2013 4:54 pm

Re: A rendering program in lua

Post by A Random Player »

robly18 wrote:So I've been thinking about a problem which I won't discuss right now because it's of no relevance, but how I have been trying to solve it.
So here's what happened... I made a basic rendering software. You have a dot on a screen, and you can use code to make it move around. So far I made a basic physics engine with bouncy balls.
Anyway, I just thought I'd ask for an opinion on it. It's actually the first time I've done anything like it and I'd like feedback!
http://notepad.cc/robrender1

Plug this code into this:
http://www.lua.org/cgi-bin/demo

Right now the physics are... Buggy, to say the least. But I'm working on improving them.
So, give me your opinion! How's my rendering code skills?
Heh, cool! Though using a grid to display continuous data isn't exactly ideal ;)
$1 = 100¢ = (10¢)^2 = ($0.10)^2 = $0.01 = 1¢ [1]
Always check your units or you will have no money!
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

Re: A rendering program in lua

Post by robly18 »

A Random Player wrote:
robly18 wrote:So I've been thinking about a problem which I won't discuss right now because it's of no relevance, but how I have been trying to solve it.
So here's what happened... I made a basic rendering software. You have a dot on a screen, and you can use code to make it move around. So far I made a basic physics engine with bouncy balls.
Anyway, I just thought I'd ask for an opinion on it. It's actually the first time I've done anything like it and I'd like feedback!
http://notepad.cc/robrender1

Plug this code into this:
http://www.lua.org/cgi-bin/demo

Right now the physics are... Buggy, to say the least. But I'm working on improving them.
So, give me your opinion! How's my rendering code skills?
Heh, cool! Though using a grid to display continuous data isn't exactly ideal ;)
Well, how do you suggest I make a way to display the information reasonably in the form of ASCII?
Convincing people that 0.9999... = 1 since 2012
A Random Player
Posts: 523
Joined: Mon Jun 03, 2013 4:54 pm

Re: A rendering program in lua

Post by A Random Player »

robly18 wrote:
A Random Player wrote:
robly18 wrote:So I've been thinking about a problem which I won't discuss right now because it's of no relevance, but how I have been trying to solve it.
So here's what happened... I made a basic rendering software. You have a dot on a screen, and you can use code to make it move around. So far I made a basic physics engine with bouncy balls.
Anyway, I just thought I'd ask for an opinion on it. It's actually the first time I've done anything like it and I'd like feedback!
http://notepad.cc/robrender1

Plug this code into this:
http://www.lua.org/cgi-bin/demo

Right now the physics are... Buggy, to say the least. But I'm working on improving them.
So, give me your opinion! How's my rendering code skills?
Heh, cool! Though using a grid to display continuous data isn't exactly ideal ;)
Well, how do you suggest I make a way to display the information reasonably in the form of ASCII?
Print the positions? :P
6
9
11
12
12
11
9
6
2
Other than that, not sure. You could try to use a larger box, or try a "graph paper" approach, plotting position vs time:

Code: Select all

   ##
  #  #

 #    #


#      #
But that's quite complicated. You could rotate CCW 90°, and get this:

Code: Select all

#
    #
        #
           #
             #
              #
              #
             #
           #
        #
    #
#
which looks (and is coded) somewhat better. In this case, you just need to concatenate a certain number of spaces.

But these methods can only show motion in one dimension. To keep two dimensions, I would try putting a border around the boxes, or maybe other "landmarks", so our eyes can easily move between the pictures and see the locations of the ball:

Code: Select all

+-------+
|       |
| \   / |
|       |
|   x   |
|       |
| /   \ |
|O      |
+-------+

+-------+
|       |
| \   / |
|       |
|   x   |
| O     |
| /   \ |
|       |
+-------+

+-------+
|       |
| \   / |
|       |
|  Ox   |
|       |
| /   \ |
|       |
+-------+

+-------+
|       |
| \   / |
|       |
|   O   |
|       |
| /   \ |
|       |
+-------+

+-------+
|       |
| \   / |
|       |
|   x   |
|    O  |
| /   \ |
|       |
+-------+
Most of all, try sticking to integer positions and velocities, unless you have a very large resolution screen (in which case it's probably better to copy to notepad to view it)

(After reviewing it in notepad, I have to say that it looks somewhat better. I guess the tiny output box is slightly to blame.)
$1 = 100¢ = (10¢)^2 = ($0.10)^2 = $0.01 = 1¢ [1]
Always check your units or you will have no money!
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

Re: A rendering program in lua

Post by robly18 »

Hm. I like the landmarks idea. However, the position over time is something I'd rather not do. The problem I have in mind requires me to have a good view of the X and Y position over time, so...
But yeah, I might add those landmarks.
Convincing people that 0.9999... = 1 since 2012
User avatar
testtubegames
Site Admin
Posts: 1148
Joined: Mon Nov 19, 2012 7:54 pm

Re: A rendering program in lua

Post by testtubegames »

Interesting question. I agree, it's kinda tough to picture how the objects are moving when it's separated into a bunch of frames. Landmarks could work, but for cleanliness, I might suggest putting a ghost trace on the ball.

So the ball is represented by some significant character. Then behind it is a trail of ghosts... some less significant characters (1, 2, or maybe even 3 steps-worth of ghosts).

My simplistic attempt at drawing it, using a capital 'O' trailed by asterisks:

------------------
| |
| O |
| * |
| * |
| * |
------------------

------------------
| |
| * O |
| * |
| * |
| |
------------------

------------------
| |
| * * |
| * O|
| |
| |
------------------

Edit: Spaces are weirdly (not) shown here, see Robly's response for a better looking version
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

Re: A rendering program in lua

Post by robly18 »

testtubegames wrote:Interesting question. I agree, it's kinda tough to picture how the objects are moving when it's separated into a bunch of frames. Landmarks could work, but for cleanliness, I might suggest putting a ghost trace on the ball.

So the ball is represented by some significant character. Then behind it is a trail of ghosts... some less significant characters (1, 2, or maybe even 3 steps-worth of ghosts).

My simplistic attempt at drawing it, using a capital 'O' trailed by asterisks:

Code: Select all

------------------
|                   |
|            O     |
|          *        |
|        *          |
|       *           |
------------------

------------------
|                   |
|            * O   |
|          *       |
|         *         |
|                   |
------------------

------------------
|                   |
|            * *   |
|          *     O|
|                   |
|                   |
------------------
That's a good idea, but I feel it would require a lot of variables. However, I'll try it when i think of a way to do it. Also, fixed your spaces.
Convincing people that 0.9999... = 1 since 2012
User avatar
testtubegames
Site Admin
Posts: 1148
Joined: Mon Nov 19, 2012 7:54 pm

Re: A rendering program in lua

Post by testtubegames »

robly18 wrote:That's a good idea, but I feel it would require a lot of variables. However, I'll try it when i think of a way to do it. Also, fixed your spaces.
Ah, whoops, that's why there's a 'preview' button... and a 'code' block. Thanks for fixing it up so I don't look (as) crazy
exfret
Posts: 585
Joined: Sun Jul 28, 2013 8:40 pm

Re: A rendering program in lua

Post by exfret »

Why don't you go in and edit your post to place the code block in there?
Nobody ever notices my signature. ):
User avatar
robly18
Posts: 413
Joined: Tue Jun 04, 2013 2:03 pm

Re: A rendering program in lua

Post by robly18 »

exfret wrote:Why don't you go in and edit your post to place the code block in there?
Because then I'd look like an idiot who fixed up nothing :lol:
Convincing people that 0.9999... = 1 since 2012
Post Reply