-
-
Save ff6347/4f8d21c538e516947ff9 to your computer and use it in GitHub Desktop.
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
| // Marius Watz - http://workshop.evolutionzone.com | |
| // | |
| // Window frame control: Disable frame decoration (see | |
| // init() function), manipulate frame position (see | |
| // keyPressed(), draw() ) | |
| int framePosX=0; | |
| int framePosY=0; | |
| boolean frameDecorated=false; | |
| void setup() { | |
| size(400, 400); | |
| background(0); | |
| } | |
| void draw() { | |
| // set frame location on startup | |
| if (frameCount<10) { | |
| frame.setLocation(framePosX, framePosY); | |
| } | |
| // yellow background | |
| background(255,255,0); | |
| // draw black rect to create fat yellow border | |
| fill(0); | |
| noStroke(); | |
| rect(5,5, width-10,height-10); | |
| fill(255,255,0); | |
| textAlign(RIGHT); | |
| text("framePosX "+framePosX,width-10,25); | |
| text("framePosY "+framePosY,width-10,40); | |
| stroke(255); | |
| line(50, 50, width-50, height-50); | |
| } | |
| // override PApplet.init() to allow us to turn off | |
| // frame decorations | |
| public void init() { | |
| if (!frameDecorated) { | |
| frame.dispose(); | |
| frame.setUndecorated(true); // works. | |
| } | |
| // call PApplet.init() to take care of usual business | |
| super.init(); | |
| } | |
| // use keys to move frame on screen | |
| void keyPressed() { | |
| int framePosModX=0, framePosModY=0; | |
| if (key=='a') framePosModX-=50; | |
| if (key=='d') framePosModX+=50; | |
| if (key=='w') framePosModY-=50; | |
| if (key=='s') framePosModY+=50; | |
| if (abs(framePosModX)>0 || abs(framePosModY)>0) { | |
| framePosX+=framePosModX; | |
| framePosY+=framePosModY; | |
| frame.setLocation(framePosX, framePosY); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment