Last active
November 20, 2017 20:08
-
-
Save vladdeSV/dcdc24cf1333188f1ed66a9450afed66 to your computer and use it in GitHub Desktop.
whoops. how about not maxing out cpu ¯\_(ツ)_/¯
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import core.thread; | |
import scone; | |
import scone.misc.ticker; | |
import std.math; | |
import std.stdio; | |
void main() | |
{ | |
bool loop = true; | |
int l = 0; | |
window.title = "Example 3"; | |
window.resize(60, 20); | |
auto ticker = Ticker(60); | |
//gameloop | |
while(loop) | |
{ | |
//only update if a tick has passed | |
//will only be run 60 times per second | |
foreach(tick; 0 .. ticker.ticks) | |
{ | |
window.clear(); | |
//check if escape is pressed, and if so, stop gameloop | |
foreach(input; window.getInputs) | |
{ | |
if(input.key == SK.escape) | |
{ | |
loop = false; | |
} | |
} | |
enum d = 13; | |
foreach(int v; 0 .. 360) | |
{ | |
real x = (cos(v*PI/180)*d) * sin(l * PI / 180); | |
real y = (sin(v*PI/180)*d) /* sin(l * PI / 180) /*/* 1/2; | |
char c = (v >= 280 && v < 340) ? '*' : ' '; | |
Color col = (v >= 110 && v < 135+90) ? Color.yellow_dark : Color.yellow; | |
window.write(cast(int)(window.w/2+x),cast(int)(window.h/2+y), fg(Color.white), bg(col), c); | |
} | |
l += 1; | |
l %= 180; | |
window.print(); | |
} | |
Thread.sleep(10.msecs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment