diff options
author | thing 1 <thing1@seacrossedlovers.xyz> | 2024-12-05 12:04:08 +0000 |
---|---|---|
committer | thing 1 <thing1@seacrossedlovers.xyz> | 2024-12-05 12:04:08 +0000 |
commit | 68baa2efd72cb150dd6138d7b208b2621bcfc431 (patch) | |
tree | fefde42e9df77384f9fa11adfa3efd3af73869d8 /comp/lucas-standen-NEA/writeup2/examples | |
parent | 27e2e13679f57eb2bd139175216b1d5989e8dc6a (diff) |
made a load of stuff
Diffstat (limited to 'comp/lucas-standen-NEA/writeup2/examples')
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/fib.example | 3 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/fib.py | 8 | ||||
-rwxr-xr-x | comp/lucas-standen-NEA/writeup2/examples/fib_example | bin | 0 -> 21280 bytes | |||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/fib_example.zpy | 13 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.png | bin | 0 -> 21285 bytes | |||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.zpy | 164 | ||||
-rwxr-xr-x | comp/lucas-standen-NEA/writeup2/examples/str_example | bin | 0 -> 17152 bytes | |||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/str_example.zpy | 17 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/string.example | 3 | ||||
-rw-r--r-- | comp/lucas-standen-NEA/writeup2/examples/zpypkg.example | 6 |
10 files changed, 214 insertions, 0 deletions
diff --git a/comp/lucas-standen-NEA/writeup2/examples/fib.example b/comp/lucas-standen-NEA/writeup2/examples/fib.example new file mode 100644 index 0000000..f013b0b --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/fib.example @@ -0,0 +1,3 @@ +give me a number (bellow 30 if you want it to be quick): 10 +55 + diff --git a/comp/lucas-standen-NEA/writeup2/examples/fib.py b/comp/lucas-standen-NEA/writeup2/examples/fib.py new file mode 100644 index 0000000..f6823af --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/fib.py @@ -0,0 +1,8 @@ +def fib(n): + if (n < 2): + return n + + return fib(n-1) + fib(n-2) + +val = 30 +print(fib(val)) diff --git a/comp/lucas-standen-NEA/writeup2/examples/fib_example b/comp/lucas-standen-NEA/writeup2/examples/fib_example Binary files differnew file mode 100755 index 0000000..130332f --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/fib_example diff --git a/comp/lucas-standen-NEA/writeup2/examples/fib_example.zpy b/comp/lucas-standen-NEA/writeup2/examples/fib_example.zpy new file mode 100644 index 0000000..2c66618 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/fib_example.zpy @@ -0,0 +1,13 @@ +(defun fib int n:int) + (if (< n 2)) + (return n) + (endif) + + (return (+ (fib (- n 1)) (fib (- n 2)))) +(endfun) + +(defun main int) + (let n:int 30) + (printint (fib n)) + (printchar '\n') +(endfun) diff --git a/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.png b/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.png Binary files differnew file mode 100644 index 0000000..c1889f7 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.png diff --git a/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.zpy b/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.zpy new file mode 100644 index 0000000..33036e0 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/spaceinvaders.zpy @@ -0,0 +1,164 @@ +(struct entity) + (def x:int) + (def y:int) + (def width:int) + (def height:int) + (def ofx:int) + (def ofy:int) + (def exists:bool) +(endstruct) + +//# this checks if 2 entitys are touching +(defun touching bool a:entity* b:entity*) + (def r1:Rectangle) + (def r2:Rectangle) + + (set r1.x a->x) + (set r1.y a->y) + (set r1.width a->width) + (set r1.height a->height) + + (set r2.x b->x) + (set r2.y b->y) + (set r2.width b->width) + (set r2.height b->height) + (return (CheckCollisionRecs r1 r2)) +(endfun) + +//# the main loop of the program +(defun main int) + (InitWindow 800 800 "test test") + (SetTargetFPS 60) + + (let p:entity* (alloc (sizeof entity))) + (set p->x 400) + (set p->y 700) + (set p->width 50) + (set p->height 30) + (set p->ofx 25) + (set p->ofy 15) + + (let b:entity* (alloc (sizeof entity))) + (set b->x 400) + (set b->y 700) + (set b->width 10) + (set b->height 6) + (set b->ofx 5) + (set b->ofy 3) + (set b->exists false) + + (let b2:entity* (alloc (sizeof entity))) + (set b2->x 400) + (set b2->y 700) + (set b2->width 10) + (set b2->height 6) + (set b2->ofx 5) + (set b2->ofy 3) + (set b2->exists false) + + (let e:entity* (alloc (sizeof entity))) + (set e->x 400) + (set e->y 100) + (set e->width 60) + (set e->height 30) + (set e->ofx 30) + (set e->ofy 15) + (set e->exists true) + + (let ehp:int 5) + (let edx:int 1) + + (let reload:int 0) + + (for i:int 0 (= (WindowShouldClose) 0) 0) + (if (= ehp 0)) + (exit 0) + (elif (= e->y 700)) + (exit 1) + (endif) + + (if (!= reload 0) + (set reload (- reload 1)) + (endif) + + (BeginDrawing) + (ClearBackground BLACK) + (DrawRectangle (- p->x p->ofx) (+ p->y p->ofy) p->width p->height GREEN) + (if (= b->exists true)) + (DrawRectangle (- b->x b->ofx) (+ b->y b->ofy) b->width b->height BLUE) + (endif) + (if (= b2->exists true)) + (DrawRectangle (- b2->x b2->ofx) (+ b2->y b2->ofy) b2->width b2->height PURPLE) + (endif) + (if (= e->exists true)) + (DrawRectangle (- e->x e->ofx) (+ e->y e->ofy) e->width e->height RED) + (endif) + (EndDrawing) + + (if (IsKeyDown KEY_LEFT)) + (set p->x (- p->x 6)) + (elif (IsKeyDown KEY_RIGHT)) + (set p->x (+ p->x 6)) + (endif) + + (if (IsKeyPressed KEY_SPACE)) + (if (= reload 0)) + (if (!= b->exists true)) + (set b->exists true) + (else) + (set b2->exists true) + (endif) + (set reload 30) + (endif) + (endif) + + (if (= b->exists true)) + (set b->y (- b->y 10)) + (if (< b->y 0)) + (set b->y 700) + (set b->exists false) + (endif) + (else) + (set b->x p->x) + (endif) + + (if (touching b e)) + (set b->y 700) + (set b->exists false) + (set ehp (- ehp 1) + (if (<= ehp 0)) + (set e->exists false) + (endif) + (endif) + + (if (= b2->exists true)) + (set b2->y (- b2->y 10)) + (if (< b2->y 0)) + (set b2->y 700) + (set b2->exists false) + (endif) + (else) + (set b2->x p->x) + (endif) + + (if (touching b2 e)) + (set b2->y 700) + (set b2->exists false) + (set ehp (- ehp 1) + (if (<= ehp 0)) + (set e->exists false) + (endif) + (endif) + + (set e->x (+ (* 4 edx) e->x) + (if (= e->x 800)) + (set edx (* edx -1) + (set e->y (+ e->y 10)) + (elif (= e->x 0)) + (set edx (* edx -1) + (set e->y (+ e->y 10)) + (endif) + + (endfor) + (CloseWindow) +(endfun) diff --git a/comp/lucas-standen-NEA/writeup2/examples/str_example b/comp/lucas-standen-NEA/writeup2/examples/str_example Binary files differnew file mode 100755 index 0000000..caddcd1 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/str_example diff --git a/comp/lucas-standen-NEA/writeup2/examples/str_example.zpy b/comp/lucas-standen-NEA/writeup2/examples/str_example.zpy new file mode 100644 index 0000000..9d2abd1 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/str_example.zpy @@ -0,0 +1,17 @@ +(defun main int) + (let str:string* (String "hello_world")) + (printstr str->_str) + (printchar '\n') + + (let strs:string** (str->split str '_')) + + (printstr strs[0]->_str) + (printchar '\n') + (printstr strs[1]->_str) + (printchar '\n') + + (strs[0]->free strs[0]) + (strs[1]->free strs[1]) + (free strs) + (str->free str) +(endfun) diff --git a/comp/lucas-standen-NEA/writeup2/examples/string.example b/comp/lucas-standen-NEA/writeup2/examples/string.example new file mode 100644 index 0000000..51ae335 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/string.example @@ -0,0 +1,3 @@ +hello_world +hello +world diff --git a/comp/lucas-standen-NEA/writeup2/examples/zpypkg.example b/comp/lucas-standen-NEA/writeup2/examples/zpypkg.example new file mode 100644 index 0000000..b4208b3 --- /dev/null +++ b/comp/lucas-standen-NEA/writeup2/examples/zpypkg.example @@ -0,0 +1,6 @@ +zpypkg init # makes a new zpypkg project +zpypkg build # make a binary of a project +zpypkg run # make a binary and run it +zpypkg clean # remove all binaries +zpypkg remove # remove zpypkg from the project + |