prog8/compiler/examples/swirl.p8

34 lines
741 B
Plaintext
Raw Normal View History

2018-09-30 23:01:39 +00:00
%option enable_floats
~ main {
const word width = 320
const word height = 200
2018-09-30 23:01:39 +00:00
sub start() {
_vm_gfx_clearscr(0)
2018-10-02 23:11:28 +00:00
_vm_gfx_text(2, 2, 7, "Swirl !!!")
2018-09-30 23:01:39 +00:00
float x
float y
float t
byte color
while(1) {
x = sin(t*1.01) + cos(t*1.1234)
y = cos(t) + sin(t*0.03456)
_vm_gfx_pixel(screenx(x), screeny(y), color//16)
2018-09-30 23:01:39 +00:00
t += 0.01
color++
}
}
sub screenx(x: float) -> word {
2018-10-05 15:44:29 +00:00
return floor(x * flt(width)/4.1) + width // 2 ; @todo const-fold x*y/z
}
sub screeny(y: float) -> word {
2018-10-05 15:44:29 +00:00
return floor(y * flt(height)/4.1) + height // 2 ; @todo const-fold x*y/z
}
2018-09-30 23:01:39 +00:00
}