Bunch of random ideas

This commit is contained in:
zongor 2024-12-07 18:44:29 -05:00
parent b4cfe77743
commit 1202fdc1dd
9 changed files with 796 additions and 132 deletions

View File

@ -1,20 +1,20 @@
# *zwl* (zongors world language) Design parameters # _zwl_ (zongors world language) Design parameters
## What is *zwl*? ## What is _zwl_?
*zwl* is an esoteric programming language that is trying way too hard to be a serious programming language. _zwl_ is an esoteric programming language that is trying way too hard to be a serious programming language.
It is inspired by both [esoteric programming languages](https://esolangs.org/wiki/Esoteric_programming_language), like [var'aq](https://web.archive.org/web/20091026213516/http://geocities.com/connorbd/varaq/), [uiua](https://www.uiua.org/), and [TIS-100 assembly](https://www.zachtronics.com/images/TIS-100P%20Reference%20Manual.pdf) and serious programming languages like C, Perl, Common Lisp, Lua, Rust, Go, Odin, Zig, Elixir, and Haskell. It is inspired by both [esoteric programming languages](https://esolangs.org/wiki/Esoteric_programming_language), like [var'aq](https://web.archive.org/web/20091026213516/http://geocities.com/connorbd/varaq/), [uiua](https://www.uiua.org/), and [TIS-100 assembly](https://www.zachtronics.com/images/TIS-100P%20Reference%20Manual.pdf) and serious programming languages like C, Perl, Common Lisp, Lua, Rust, Go, Odin, Zig, Elixir, and Haskell.
## What are the features in *zwl*? ## What are the features in _zwl_?
In general the paradigms are designed to be: var'aq-like, Interpreted, Distributed, Concurrent, and have an option to be JIT. In general the paradigms are designed to be: var'aq-like, Interpreted, Distributed, Concurrent, and have an option to be JIT.
## What is the purpose of this language? ## What is the purpose of this language?
*zwl* acts as the assembly language for the universe machine. it allows for a user to manipulate the world machine. _zwl_ acts as the assembly language for the universe machine. it allows for a user to manipulate the world machine.
# *zwl* Grammar and Specification # _zwl_ Grammar and Specification
How do I read these operations? How do I read these operations?
@ -34,15 +34,16 @@ unless stated you should assume that any arguments are pushed or poped from the
- atoms (invoked forms) are stored in the internal database which is why they need version numbers - atoms (invoked forms) are stored in the internal database which is why they need version numbers
- Forms can be implementations of interfaces, collsions are not important as the names of interfaces only carry what needs to be implemented a not any implemtntation itself. for people coming from OOP you can think of this similar to an abstract class. - Forms can be implementations of interfaces, collsions are not important as the names of interfaces only carry what needs to be implemented a not any implemtntation itself. for people coming from OOP you can think of this similar to an abstract class.
- there are also a list of "substantial forms" which come with the language which are the building blocks for more complex forms. If you are coming from object oriented languages you can think of this as "primitive types" - there are also a list of "substantial forms" which come with the language which are the building blocks for more complex forms. If you are coming from object oriented languages you can think of this as "primitive types"
- the "constructor" of it is
- string for the name of the form
- this returns how many dimensions it can exist in, 0th means non drawable, 2 means 2D GUI usually, 3 means 3D object, and >3 is somthing you will have to implement yourself, e.g. miegakure
- this is for the unit/measures system
- some kind of procedure to draw the element in space or None
- a position in space or None
- the list of allowed forms that can be used as input
- a list containing the data of that form
string for the command "form-name" «dimensions» «unit» «display» «position» («list» «of» «allowed» «input» «forms» …) («data» …) `frmdef` -
this returns how many dimensions it can exist in, 0th means non drawable, 2 means 2D GUI usually, 3 means 3D object, and >3 is somthing you will have to implement yourself, e.g. miegakure
this is for the unit/measures system
some kind of procedure to draw the element in space or None
a position in space or None
a list containing the data of that form
"form name" «dimensions» «unit» «display» «position» «data» `frmdef` -
# Substantial Forms # Substantial Forms
@ -50,7 +51,7 @@ a list containing the data of that form
### bit (or unsigned units) ### bit (or unsigned units)
«hex number» 8 `u` u8 «hex number» 8 `u` u8
«hex number» «hex number» 16 `u` u16 «hex number» «hex number» 16 `u` u16
@ -60,7 +61,7 @@ a list containing the data of that form
### integer (signed) ### integer (signed)
«hex number» 8 `i` u8 «hex number» 8 `i` u8
«hex number» «hex number» 16 `i` u16 «hex number» «hex number» 16 `i` u16
@ -83,9 +84,11 @@ strings are always utf8, other formats will need to be done manually
## logical ## logical
### true ### true
- `true` bool - `true` bool
### false ### false
- `false` bool - `false` bool
### panic ### panic
@ -106,53 +109,105 @@ A list will act similar to a list in LISP, it is esentially a block of memory th
The following is a list of global operators and their effect: The following is a list of global operators and their effect:
comment (looks for another ! to close) #### comment (looks for another ! to close)
! any raw text here `!` - ! any raw text here `!` -
anonymous subtroutine #### anonymous subtroutine
{ … `}` subroutine { … `}` subroutine
sets a value in the node's map #### sets a value in the node's map
`set`
delete from node's map "«name of the value [no spaces]»" «value» `set` -
`del`
`add` #### delete from node's map
`sub` «name-of-the-item» `del`
`mul` #### adds the top values on the stack
`div`
`pow`
`eq`
`ne`
`mod`
`not`
`and`
`or`
`nor` num num `add` num (of same type)
`nand` #### subtracts the top values on the stack
`xor` num num `sub` num (of same type)
`band` #### multiplys the top values on the stack
`bor` num num `mul` num (of same type)
`bnor` #### divides the top values on the stack
`bxor` num num `div` num (of same type)
#### does a n'th power the top values on the stack
num num `pow` num (of same type)
#### returns the divisor of the top values on the stack
num num `mod` num (of same type)
#### checks if the top values on the stack are equal
val val `eq` bool
#### checks if the top values on the stack are not equal
val val `ne` bool
#### checks if the top values on the stack are equal
val val `not` bool
#### does an and operation on the top of the stack
bool bool `and` bool
#### does an or operation on the top of the stack
bool bool `or` bool
#### does an not-or operation on the top of the stack
bool bool `nor` bool
#### does an not-and operation on the top of the stack
bool bool `nand` bool
#### does an exclusive or operation on the top of the stack
bool bool `xor` bool
#### does an bitwise and operation on the top of the stack
val val `band` val (of same type)
#### does an bitwise or operation on the top of the stack
val val `bor` val (of same type)
#### does an bitwise nor operation on the top of the stack
val val `bnor` val (of same type)
#### does an bitwise xor operation on the top of the stack
val val `bxor` val (of same type)
#### does an bitwise shift left
val num `sll` val (of same type)
#### does an bitwise shift right
val num `srl` val (of same type)
#### checks the form of the value on top of the stack
«value» «form» `?` bool
## Atom ## Atom
@ -182,80 +237,96 @@ note the form must always be of a form which is "tunnel-able" i.e. Files, socket
«field», … `«tunnel-able form»` tunnel «field», … `«tunnel-able form»` tunnel
open communication #### open communication
tunnel args, … `attach` bool tunnel args, … `attach` bool tunnel
close communication #### close communication
tunnel `clunk` bool tunnel tunnel `clunk` bool
cancels long operation and dumps whatever is in buffer #### cancels long operation and dumps whatever is in buffer
tunnel `flush` bool tunnel tunnel `flush` bool tunnel
opens a tunnel for doing operations on #### opens a tunnel for doing operations on
tunnel resource mode `open` bool tunnel tunnel resource mode `open` bool tunnel
creates the object from the database graph/file from file structure #### creates the object from the database graph/file from file structure
tunnel resource `create` bool tunnel tunnel resource `create` bool tunnel
reads from a tunnel #### reads from a tunnel
tunnel resource `read` «form» tunnel tunnel resource `read` «form» tunnel
writes to a tunnel, gets response from endpoint #### writes to a tunnel, gets response from endpoint
tunnel resource data `write` bool tunnel tunnel resource data `write` bool tunnel
removes the object from the database graph/file from file structure #### removes the object from the database graph/file from file structure
tunnel resource `remove` bool tunnel tunnel resource `remove` bool tunnel
returns the status of the file/resource #### returns the status of the file/resource
tunnel resource `stat` tunnel «status data» tunnel resource `stat` tunnel «status data»
returns the version code for the connected tunnel, returns of version info #### returns the version code for the connected tunnel, returns of version info
tunnel `version` (list) tunnel tunnel `version` (list) tunnel
moves around the filesystem or through the graph #### moves around the filesystem or through the graph
tunnel "path_or_endpoint" `walk` bool tunnel
tunnel "path-or-endpoint" `walk` bool tunnel
#### example #### example
``` ```
"echo_tunnel" "user" "auth" "http://example.com" url attach set ! create a new tunnel called "echo tunnel" and attach it to the resource "echo-tunnel" "user" "auth" "http://example.com" url attach set ! create a new tunnel called "echo tunnel" and attach it to the resource !
"hello world" "/some/rest/echo" echo_tunnel open pop write ! open the endpoint and read write the "hello world" to it "hello world" "/some/rest/echo" echo-tunnel open pop write ! open the endpoint and read write the "hello world" to it !
echo_tunnel read std write ! syncronously read in the data echoed back from the endpoint and print it to stdout echo-tunnel read std write ! syncronously read in the data echoed back from the endpoint and print it to stdout !
flush flush
clunk pop clunk pop
"echo_tunnel" del "echo-tunnel" del
``` ```
in "terminal mode" the default tunnel is std in "terminal mode" the default tunnel is std
in "web mode" the default tunnels are log, info, trace, warn, error, but note these are all special tunnels which only accept write commands in "web mode" the default tunnels are log, info, trace, warn, error, but note these are all special tunnels which only accept write commands
### built in tunnleable forms
#### file
A file that exists on the local filesystem
#### http
A file or data endpoint that exists on the internet or other network using the http protocol
#### https
A file or data endpoint that exists on the internet or other network using the https protocol
#### 9p
A file or data endpoint that exists on the internet or other network using the 9p protocol
## subroutines ## subroutines
``` { «instructions» `}`
{
«instructions»
}
```
- Built in subroutines - Subroutines in stdlib
- sort - sort
- filter - filter
- trig functions - trig functions
- calc functions - calc functions
- statistical functions - statistical functions
- I/O
- networking
- more...
## Control flow ## Control flow
@ -263,55 +334,61 @@ in "web mode" the default tunnels are log, info, trace, warn, error, but note th
runs the subroutine infinitely until it breaks or panics runs the subroutine infinitely until it breaks or panics
{ «body» } `loop` - { «body» } `loop` ?
runs the subroutine a given number of times runs the subroutine a given number of times
«some numeric value» { «body» } `repeat` - «some numeric value» { «body» } `repeat` ?
runs the subroutine a given number of times runs the subroutine for each element on the stack
{ «body» } `map` ?
## Libraries and “includes” ## Libraries and “includes”
In most languages the include or use statements get libraries which link to other files and so on. This quickly gets confusing and so requires package managers and installers, etc. In most languages the include or use statements get libraries which link to other files and so on. This quickly gets confusing and so requires package managers and installers, etc.
The other way to do this would be to just specifically “name” the paths using a tunnel and import it. You can even use localization tokens to create config files. The other way to do this would be to just specifically “name” the paths using a tunnel and import it. You can even use localization tokens to create config files.
Since everything is lazily compiled jit anyways it (in theory) doesn't hurt performance much Since everything is lazily compiled jit anyways it (in theory) doesn't hurt performance much.
"https://raw.githubusercontent.com/some_user/some_library/some_file.zwl" `import` The import subroutine takes in a tunnel and evaluates the contents in the node. import the same as creating a tunnel, reading the contents, and evaluating the response.
"./some_local_file.zwl" `import` "«string of resource location»" «tunnel-able form» `import` -
For example:
```
"./some_local_file.zwl" file import ! imports a local file
"/lib/stdlib.zwl" file import ! imports the standard library
"/some_user/some_library/some_file.zwl" "raw.githubusercontent.com" https import ! imports the contents of this url
```
## Universe ## Universe
All forms and complications exist within the universe. All forms and complications exist within the universe.
The universe can be thought of as the "global" namespace in an object oriented language or as the kernel for the "atom processes" to exist in. The universe can be thought of as the "global" namespace in an object oriented language or as the kernel for the "atom processes" to exist in.
a "main" space should be created that invokes the required startup atoms of the syntax. a "main" space should be created that invokes the required startup atoms of the syntax.
in kOS this actually *is* the kernel layer in kOS this actually _is_ the kernel layer
## GUI ## GUI
The GUI is inspired by PicoLisp and Electron, using a web browser engine to render the GUI including 3D stuff like webgl. The GUI is inspired by PicoLisp and Electron, using a web browser engine to render the GUI including 3D stuff like webgl.
Most html elements have an analogous form in *zwl*: Tables, lists, links, buttons, input boxes, etc. Most html elements have an analogous form in _zwl_: Tables, lists, links, buttons, input boxes, etc.
In kOS these are replaces by its own version of these forms. In kOS these are replaces by its own version of these forms.
These of course can be wrapped in your own implementations. The idea is that on *zwls* side all UI is unified by forms but also is interoperable with HTML, templating engines, or gui libraries These of course can be wrapped in your own implementations. The idea is that on _zwls_ side all UI is unified by forms but also is interoperable with HTML, templating engines, or gui libraries
## Concurrency ## Concurrency
As in elixir there are as many schedulers as there are cores for your cpu As in elixir there are as many schedulers as there are cores for your cpu
Like in CM and real time micro architecture systems like QNX tasks are scheduled based on priority and must stay within a time limit or it will be “punished” into a lower priority Like in CM and real time micro architecture systems like QNX tasks are scheduled based on priority and must stay within a time limit or it will be “punished” into a lower priority
Threading in *zwl* are split up into tasks (which take input) and daemons (which take no input) Threading in _zwl_ are split up into tasks (which take input) and daemons (which take no input)
Tasks are spawned whereas daemons are summoned Tasks are spawned whereas daemons are summoned
Message passing can be achieved by using tunnels. Message passing can be achieved by using tunnels.
probably should take concurrency stuff from golang; its very nice probably should take concurrency stuff from golang; its very nice
# Appendicies # Appendicies
## Modern programming languages in the 21st century usually have need for the following requirements
### Data ### Data
- describing data - describing data
@ -327,7 +404,34 @@ probably should take concurrency stuff from golang; its very nice
- sentiment analysis - sentiment analysis
- more... - more...
- measurements - measurements
- tons of these... - time
- unit
- seconds (s)
- subforms
- date
- Default is ISO 8601
- length
- unit
- metre (m)
- subforms
- angle
- radian (rad)
- mass
- unit
- kilogram (kg)
- electric current
- unit
- ampere (a)
- temperature
- unit
- kelvin (K)
- amount of substance
- unit
- mol (mol)
- luminous intensity
- unit
- candela (candela)
- more...
### Inputing data ### Inputing data
@ -377,14 +481,14 @@ probably should take concurrency stuff from golang; its very nice
### Displaying data ### Displaying data
- objects - objects
- 3d models - 3d models
- 2d models - 2d models
- graphs - graphs
- tables - tables
- infographics - infographics
- written output - written output
- ai generated text - ai generated text
### System/World Objects ### System/World Objects
@ -414,7 +518,9 @@ probably should take concurrency stuff from golang; its very nice
- documentation - documentation
- tutorials - tutorials
- generating objects automatically like - metaprogramming
- macros
- generating objects automatically
### Data Description ### Data Description
@ -440,36 +546,3 @@ probably should take concurrency stuff from golang; its very nice
- read - read
- update - update
- delete - delete
## Measurement
- forms
- time
- unit
- seconds (s)
- subforms
- date
- Default is ISO 8601
- length
- unit
- metre (m)
- subforms
- angle
- radian (rad)
- mass
- unit
- kilogram (kg)
- electric current
- unit
- ampere (a)
- temperature
- unit
- kelvin (K)
- amount of substance
- unit
- mol (mol)
- luminous intensity
- unit
- candela (candela)

39
idea.vq Normal file
View File

@ -0,0 +1,39 @@
(255 255 0) ~ purple set
~ main {
800 ~ screen_width set
450 ~ screen_height set
argv split
~ username set
~ password set
(username (0.0 1.0 2.0) purple) ~ me set
(password) me login cons ~ players set
() () me shatter pop exch pop shatter cons
10.0 add cons
10.0 add cons
me shatter pop exch pop cons
(0.0 1.0 0.0) cons
45.0 cons
"CAMERA_PERSPECTIVE" cons
~ camera set
screen_width screen_height "zwl client : raylib" init_window
60 set_target_fps
{
(* Do handling in here *)
end_mode_3d
end_drawing
} window_should_close repeat (* Detect window close button or ESC key *)
me logout ~ players set
close_window (*Close window and OpenGL context *)
} set
main

110
idea.zl0 Normal file
View File

@ -0,0 +1,110 @@
:vec {
<f32> :x
<f32> :y
<f32> :z
} type
:color {
<i8> :r
<i8> :g
<i8> :b
} type
:player {
<str> :username
<vec> :pos
<color> :color
} type
:login {
<player> 0 check
<str> 1 check
(* do the login here *)
} sub
255 255 0 <color> new :purple set
:main {
800 <i32> new :screen_width set
450 <i32> new :screen_height set
argv split
<str> new :username set
<str> new :password set
username (0.0 1.0 2.0) purple <player> new :me set
password me login <(player)> new :players set
() me (:pos :x) acc push
me (:pos :y) acc 10.0 add push
me (:pos :z) acc 10.0 add push (* Camera pos *)
() me (:pos :x) acc push
me (:pos :y) acc push
me (:pos :z) acc push (* Camera looking at point *)
(0.0 1.0 0.0) (* Camera up vector(rotation towards target) *)
45.0 (* Camera field - of - view Y *)
:CAMERA_PERSPECTIVE (* Camera projection type *)
<Camera3D> new :camera set
screen_width screen_height "zwl client : raylib" init_window
60 set_target_fps
(* Main game loop *)
{
:KEY_RIGHT is_key_down {
0.2 me (:pos :x) acc inc me (:pos :x) mut :me set
true :player_updated set
} ifyes
:KEY_LEFT is_key_down {
0.2 me (:pos :x) acc dec me (:pos :x) mut :me set
true :player_updated set
} ifyes
:KEY_DOWN is_key_down {
0.2 me (:pos :z) acc inc me (:z :pos) mut :me set
true :player_updated set
} ifyes
:KEY_UP is_key_down {
0.2 me (:pos :z) acc dec me (:z :pos) mut :me set
true :player_updated set
} ifyes
camera me sync_camera
player_updated choose {
me move :players set
} ifyes {
me ping :players set
} isubo
begin_drawing
RAYWHITE clear_background
camera begin_mode_3d
(* Draw floor *)
30 1.0 draw_grid
me .pos 0.5 0.5 0.5 me .apperance draw_cube
players {
.pos 0.5 0.5 0.5 .apperance draw_cube
} map
end_mode_3d
end_drawing
}
{ window_should_close not } while (* Detect window close button or ESC key *)
:players me logout set
close_window() (*Close window and OpenGL context *)
} sub
main

110
idea.zl1 Normal file
View File

@ -0,0 +1,110 @@
type :vec {
<f32> :x
<f32> :y
<f32> :z
}
type :color {
<i8> :r
<i8> :g
<i8> :b
}
type :player {
<str> :username
<vec> :pos
<color> :color
}
fn :login {
check 0 <player>
check 1 <str>
(* do the login here *)
}
set :purple new <color> [255 255 0]
fn :main {
set :screen_width new <i32> 800
set :screen_height new <i32> 450
split argv
set :username new <str>
set :password new <str>
set :me new <player> [
username
new <vec> [0.0 1.0 2.0]
purple
]
set :players <(<player>)> login me password
set :camera new <Camera3D> [
new <vec> [0.0 1.0 0.0]
new <i32> 45.0
:CAMERA_PERSPECTIVE
new <vec> [add [acc me (:pos :x)] 10.0] [add [acc me (:pos :y)] 10.0] [acc me (:pos :z)]
new <vec> [acc me :pos]
]
init_window screen_width screen_height "zwl client : raylib"
set_target_fps 60
(* Main game loop *)
while { not window_should_close } {
if is_key_down :KEY_RIGHT {
mut :me (:pos :x) add [acc me :pos :x] 0.2
set :player_updated true
}
if is_key_down :KEY_LEFT {
mut :me (:pos :x) sub [acc me :pos :x] 0.2
set :player_updated true
}
if is_key_down :KEY_DOWN {
mut :me (:pos :z) add [acc me :pos :z] 0.2
set :player_updated true
}
if is_key_down :KEY_UP {
mut :me (:pos :z) sub [acc me :pos :z] 0.2
set :player_updated true
}
sync_camera camera me
if player_updated {
set :players move me
} else {
set :players ping me
}
begin_drawing
clear_background RAYWHITE
begin_mode_3d camera
(* Draw floor *)
draw_grid 30 1.0
draw_cube [acc me :pos] 0.5 0.5 0.5 [acc me :apperance]
map players {
draw_cube [acc @this :pos] 0.5 0.5 0.5 [acc @this apperance]
}
end_mode_3d
end_drawing
}
(* Detect window close button or ESC key *)
players = me.logout()
close_window() (*Close window and OpenGL context *)
}
main

113
idea.zl2 Normal file
View File

@ -0,0 +1,113 @@
type :Vec {
f32 :x
f32 :y
f32 :z
}
type :Color {
i8 :r
i8 :g
i8 :b
}
type :Player {
Str :username
Vec :pos
Color :color
}
fn :login {
Player
str
(* do the login here *)
}
Color :purple {255 255 0}
fn :main {
i32 :screen_width 800
i32 :screen_height 450
split argv
str :username
str :password
Player :me {
username
vec {0.0 1.0 2.0}
purple
}
Player() :players { login me password }
Camera3D :camera {
vec {0.0 1.0 0.0}
i32 45.0
atom :CAMERA_PERSPECTIVE
vec {
add acc (:me :pos :x) 10.0
add acc (:me :pos :y) 10.0
acc (:me :pos :z)
}
vec {acc me :pos}
}
init_window "zwl client : raylib" screen_width screen_height
set_target_fps 60
(* Main game loop *)
while { not window_should_close } {
if {is_key_down :KEY_RIGHT} {
mut (:me :pos :x) add acc me :pos :x 0.2
set :player_updated true
}
if {is_key_down :KEY_LEFT} {
mut (:me :pos :x) sub acc me :pos :x 0.2
set :player_updated true
}
if {is_key_down :KEY_DOWN} {
mut (:me :pos :z) add acc me :pos :z 0.2
set :player_updated true
}
if {is_key_down :KEY_UP} {
mut (:me :pos :z) sub acc me :pos :z 0.2
set :player_updated true
}
sync_camera camera me
if (player_updated) {
set :players move me
} else {
set :players ping me
}
begin_drawing
clear_background RAYWHITE
begin_mode_3d camera
(* Draw floor *)
draw_grid 30 1.0
draw_cube [acc me :pos] 0.5 0.5 0.5 [acc me :apperance]
map players {
draw_cube [acc @this :pos] 0.5 0.5 0.5 [acc @this apperance]
}
end_mode_3d
end_drawing
}
(* Detect window close button or ESC key *)
set :players logout me
close_window (*Close window and OpenGL context *)
}
main

31
old/idea.md Normal file
View File

@ -0,0 +1,31 @@
```c / zig + lisp like
(fn main (argc :i32 argv :[str]) (v :i32) (
(set message (concat "hello " (get argv 1) " !\n" ))
(write :std message)
(set v 0)))
```
```c + zig like
i32 main(i32 argc, str[] argv) {
str message = concat("hello ", argv[1], " !\n");
write(:std, message);
return 0;
}
```
```lisp like
(set message (concat "Hello " (get argv 1) " !\n"))
(write 0 message)
```
```forth + lisp / var'aq like
"Hello " argv shatter strtie " !\n" strtie disp
```
```fortran c / zig + fortran like
program main {
str message = concat("hello ", argv[1], "! \n")
write(0, "%s", message)
}
```

82
old/idea.zl-f90 Normal file
View File

@ -0,0 +1,82 @@
program main
use raylib
use player
use json
i32 screen_width = 800
i32 screen_height = 450
i32 i, status
f32 time
bool player_updated, exist
str username
str password
call getarg(1, username)
call getarg(2, password)
open(u, file=file_input)
defer close(u)
inquire(unit=u, size=sz)
Player me(username=username, pos=(0.0, 1.0, 2.0), apperance=PURPLE)
Player(:) players = me.login(password)
Camera3D camera = Camera3D(pos = (me.pos.x, me.pos.y + 10.0, me.pos.z + 10.0), !Camera pos
target = (me.pos.x, me.pos.y, me.pos.z), !Camera looking at point
up = (0.0, 1.0, 0.0), !Camera up vector(rotation towards target)
fovy = 45.0, !Camera field - of - view Y
projection = CAMERA_PERSPECTIVE) !Camera projection type
init_window(screen_width, screen_height, "zwl client : raylib")
set_target_fps(60)
!Main game loop
do while (.not. window_should_close()) ! Detect window close button or ESC key
if (is_key_down(KEY_RIGHT)) then
me.pos.x += 0.2
player_updated = .true.
else if (is_key_down(KEY_LEFT)) then
me.pos.x -= 0.2
player_updated = .true.
else if (is_key_down(KEY_DOWN)) then
me.pos.z += 0.2
player_updated = .true.
else if (is_key_down(KEY_UP)) then
me.pos.z -= 0.2
player_updated = .true.
end if
me.sync_camera(camera)
time = get_time()
if (modulo(time, 1.0) .ge. 0.98) then
if (player_updated) then
players = me.move()
else
players = me.ping()
end if
end if
begin_drawing()
clear_background(RAYWHITE)
begin_mode_3d(camera)
! Draw floor
draw_grid(30, 1.0)
draw_cube(me.pos, 0.5, 0.5, 0.5, me.apperance)
do i = 1, size(players)
draw_cube(players(i).pos, 0.5, 0.5, 0.5, players(i).apperance)
end do
end_mode_3d()
end_drawing()
end do
players = me.logout()
close_window() !Close window and OpenGL context
end program

43
old/idea.zl-lisp Normal file
View File

@ -0,0 +1,43 @@
(set screen-width 800)
(set screen-height 450)
(set username (get argv 1))
(set password (get argv 2))
(set me (make-player username (0.0 1.0 2.0) PURPLE))
(set players (login me))
(set camera (make-camera (me.pos.x, me.pos.y + 10.0, me.pos.z + 10.0)
(me.pos.x, me.pos.y, me.pos.z)
(0.0, 1.0, 0.0)
45.0
CAMERA-PERSPECTIVE))
(init-window screen-width screen-height "lisp-ish client : raylib")
(set-target-fps 60)
(using-window
(while (not (window-should-close))
(case
(is-key-down KEY-RIGHT (
(inc me.pos.x 0.2)
(set player-updated t)))
(is-key-down KEY-LEFT (
(dec me.pos.x 0.2)
(set player-updated t)))
(is-key-down KEY-DOWN (
(inc me.pos.z 0.2)
(set player-updated t)))
(is-key-down KEY-UP (
(dec me.pos.z 0.2)
(set player-updated t))))
(sync-camera me camera)
(choose (player-updated)
(set players (move me))
(set players (ping me)))
(begin-drawing (
(clear-background RAYWHITE)
(begin-mode-3d camera (
(draw-grid 30 1.0)
(draw-cube me.pos 0.5 0.5 0.5 me.apperance)
(for-each (player) players (
(draw-cube player.pos 0.5 0.5 0.5 player.apperance)))))))))

63
old/idea.zl-zigish Normal file
View File

@ -0,0 +1,63 @@
i32 main(i32 argc, str argv[]) {
i32 screen_width = 800
i32 screen_height = 450
str username = argv[1]
str password = argv[2]
Player me(username=username, pos=(0.0, 1.0, 2.0), apperance=PURPLE)
Player[] players = me.login(password)
Camera3D camera(pos = (me.pos.x, me.pos.y + 10.0, me.pos.z + 10.0), //Camera pos
target = (me.pos.x, me.pos.y, me.pos.z), //Camera looking at point
up = (0.0, 1.0, 0.0), //Camera up vector(rotation towards target)
fovy = 45.0, //Camera field - of - view Y
projection = CAMERA_PERSPECTIVE) //Camera projection type
init_window(screen_width, screen_height, "zwl client : raylib")
set_target_fps(60)
//Main game loop
do while (.not. window_should_close()) { // Detect window close button or ESC key
if (is_key_down(KEY_RIGHT)) {
me.pos.x = me.pos.x + 0.2
player_updated = .true.
} else if (is_key_down(KEY_LEFT)) {
me.pos.x = me.pos.x - 0.2
player_updated = .true.
} else if (is_key_down(KEY_DOWN)) {
me.pos.z = me.pos.z + 0.2
player_updated = .true.
} else if (is_key_down(KEY_UP)) {
me.pos.z = me.pos.z - 0.2
player_updated = .true.
}
me.sync_camera(camera)
if (player_updated) {
players = me.move()
} else {
players = me.ping()
}
begin_drawing()
clear_background(RAYWHITE)
begin_mode_3d(camera)
// Draw floor
draw_grid(30, 1.0)
draw_cube(me.pos, 0.5, 0.5, 0.5, me.apperance)
do (int i = 0; size(players)) {
draw_cube(players[i].pos, 0.5, 0.5, 0.5, players[i].apperance)
}
end_mode_3d()
end_drawing()
}
players = me.logout()
close_window() //Close window and OpenGL context
}