mirror of
https://github.com/exoticorn/curlywas.git
synced 2026-01-20 11:46:43 +01:00
ported technotunnel
This commit is contained in:
@@ -5,11 +5,11 @@ import "math.cos" fn cos(f32) -> f32;
|
|||||||
export fn tic(time: i32) {
|
export fn tic(time: i32) {
|
||||||
let i: i32;
|
let i: i32;
|
||||||
loop screen {
|
loop screen {
|
||||||
let x = (i % 320) as f32 / 48 as f32;
|
let defer x = (i % 320) as f32 / 48 as f32;
|
||||||
let y = (i / 320) as f32 / 48 as f32;
|
let defer y = (i / 320) as f32 / 48 as f32;
|
||||||
let t = time as f32 / 200 as f32;
|
let defer t = time as f32 / 200 as f32;
|
||||||
|
|
||||||
i?120 = (sin(x + t) * 32 as f32) as i32 + 128;
|
i?120 = ((sin(x + sin(y - t / 4 as f32) * 3 as f32 + t / 5 as f32) + sin(y + sin(x - t / 3 as f32) + t / 6 as f32)) * 63 as f32) as i32 + 128;
|
||||||
|
|
||||||
branch_if (i := i + 1) < 320*256: screen
|
branch_if (i := i + 1) < 320*256: screen
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -546,6 +546,8 @@ fn builtin_function(name: &str, params: &[ast::Type]) -> Option<Instruction<'sta
|
|||||||
let inst = match (name, params) {
|
let inst = match (name, params) {
|
||||||
("sqrt", &[F32]) => Instruction::F32Sqrt,
|
("sqrt", &[F32]) => Instruction::F32Sqrt,
|
||||||
("abs", &[F32]) => Instruction::F32Abs,
|
("abs", &[F32]) => Instruction::F32Abs,
|
||||||
|
("min", &[F32, F32]) => Instruction::F32Min,
|
||||||
|
("max", &[F32, F32]) => Instruction::F32Max,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some(inst)
|
Some(inst)
|
||||||
|
|||||||
@@ -674,6 +674,8 @@ fn builtin_function_types(name: &str) -> Option<(&'static [ast::Type], Option<as
|
|||||||
let types: (&'static [ast::Type], Option<ast::Type>) = match name {
|
let types: (&'static [ast::Type], Option<ast::Type>) = match name {
|
||||||
"sqrt" => (&[F32], Some(F32)),
|
"sqrt" => (&[F32], Some(F32)),
|
||||||
"abs" => (&[F32], Some(F32)),
|
"abs" => (&[F32], Some(F32)),
|
||||||
|
"min" => (&[F32, F32], Some(F32)),
|
||||||
|
"max" => (&[F32, F32], Some(F32)),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
Some(types)
|
Some(types)
|
||||||
|
|||||||
25
technotunnel.cwa
Normal file
25
technotunnel.cwa
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import "env.memory" memory(4);
|
||||||
|
import "math.sin" fn sin(f32) -> f32;
|
||||||
|
import "math.atan2" fn atan2(f32, f32) -> f32;
|
||||||
|
|
||||||
|
export fn tic(time: i32) {
|
||||||
|
let i: i32;
|
||||||
|
loop screen {
|
||||||
|
let defer t = time as f32 / 2000 as f32;
|
||||||
|
let defer o = sin(t) * 0.8;
|
||||||
|
let defer q = (i % 320) as f32 - 160.1;
|
||||||
|
let defer w = (i / 320 - 128) as f32;
|
||||||
|
let defer r = sqrt(q*q + w*w);
|
||||||
|
let defer z = q / r;
|
||||||
|
let defer s = z * o + sqrt(z * z * o * o + 1 as f32 - o * o);
|
||||||
|
let defer q2 = (z * s - o) * 10 as f32 + t;
|
||||||
|
let defer w2 = w / r * s * 10 as f32 + t;
|
||||||
|
let defer s2 = s * 50 as f32 / r;
|
||||||
|
i?120 = max(
|
||||||
|
0 as f32,
|
||||||
|
((q2 as i32 ^ w2 as i32 & ((s2 + t) * 20 as f32) as i32) & 5) as f32 *
|
||||||
|
(2 as f32 - s2) * 22 as f32
|
||||||
|
) as i32;
|
||||||
|
branch_if (i := i + 1) < 320*256: screen
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user