2018-09-30 23:01:39 +00:00
|
|
|
%option enable_floats
|
|
|
|
|
|
|
|
~ irq {
|
|
|
|
word global_time
|
|
|
|
byte time_changed
|
|
|
|
|
|
|
|
sub irq() {
|
|
|
|
global_time++
|
|
|
|
time_changed = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~ main {
|
|
|
|
|
|
|
|
const word width = 320
|
|
|
|
const word height = 200
|
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
float[6] xcoor = [-1.0, 1.0, 1.0, 0.5, 0.2, -1.0]
|
|
|
|
float[6] ycoor = [1.0, 1.0, -1.0, -0.3, -0.6, -1.0]
|
2018-09-30 23:01:39 +00:00
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
float[len(xcoor)] rotatedx
|
|
|
|
float[len(ycoor)] rotatedy
|
2018-09-30 23:01:39 +00:00
|
|
|
|
|
|
|
sub start() {
|
2018-10-02 01:07:46 +00:00
|
|
|
byte i
|
2018-09-30 23:01:39 +00:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if irq.time_changed {
|
|
|
|
irq.time_changed = 0
|
|
|
|
_vm_gfx_clearscr(0)
|
2018-10-02 01:07:46 +00:00
|
|
|
_vm_gfx_text(120, 40, 5, "Spin to Win !!!")
|
|
|
|
|
|
|
|
for i in 0 to width//10 {
|
|
|
|
_vm_gfx_line(i*2+100, 100, i*10, 199, 6)
|
|
|
|
}
|
|
|
|
|
|
|
|
rotate_points(flt(irq.global_time) / 30.0)
|
|
|
|
draw_lines()
|
2018-09-30 23:01:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
sub rotate_points(t: float) {
|
2018-09-30 23:01:39 +00:00
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
; rotate around origin (0,0) and zoom a bit
|
|
|
|
byte i
|
|
|
|
float zoom
|
|
|
|
zoom = (0.6 + sin(t*1.4)/2.2)
|
2018-09-30 23:01:39 +00:00
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
for i in 0 to len(xcoor)-1 {
|
|
|
|
rotatedx[i] = xcoor[i] * cos(t) - ycoor[i] * sin(t)
|
|
|
|
rotatedy[i] = xcoor[i] * sin(t) + ycoor[i] * cos(t)
|
|
|
|
rotatedx[i] *= zoom
|
|
|
|
rotatedy[i] *= zoom
|
|
|
|
}
|
2018-09-30 23:01:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-02 01:07:46 +00:00
|
|
|
sub draw_lines() {
|
|
|
|
byte i
|
|
|
|
|
|
|
|
sub toscreenx(x: float) -> word {
|
|
|
|
return floor(x * height/3 + width /2)
|
|
|
|
}
|
|
|
|
|
|
|
|
sub toscreeny(y: float) -> word {
|
|
|
|
return floor(y * height/3 + height /2)
|
|
|
|
}
|
|
|
|
|
|
|
|
for i in 0 to len(xcoor)-2 {
|
|
|
|
_vm_gfx_line(toscreenx(rotatedx[i]), toscreeny(rotatedy[i]), toscreenx(rotatedx[i+1]), toscreeny(rotatedy[i+1]), i+7)
|
|
|
|
}
|
|
|
|
_vm_gfx_line(toscreenx(rotatedx[len(xcoor)-1]), toscreeny(rotatedy[len(xcoor)-1]), toscreenx(rotatedx[0]), toscreeny(rotatedy[0]), 14)
|
2018-09-30 23:01:39 +00:00
|
|
|
}
|
|
|
|
}
|