11 IF - Überblick

PaintPro Extreme v0.1

by Lukas Schauer

/**
 * Lukas2511
 * PaintProExtreme v0.1
 */
import sum.kern.*;
 
 
public class PaintProExtreme
{
    // Objekte
    Buntstift stift1;
    Maus maus1;
    Bildschirm bildschirm1;
    Tastatur tastatur1;
    int farbe;
    // Attribute
 
    // Konstruktor
    public PaintProExtreme()
    {
        stift1 = new Buntstift();
        maus1 = new Maus();
        bildschirm1 = new Bildschirm(); //500,400);
        tastatur1 = new Tastatur();
        farbe = Farbe.SCHWARZ;
    }
 
    public void farbwechsel(){
        if(maus1.hPosition()<100 && maus1.istGedrueckt()){
            if(maus1.hPosition()>=10 && maus1.hPosition()<=30 && maus1.vPosition()>=10 && maus1.vPosition()<=30){
                stift1.setzeFarbe(Farbe.SCHWARZ);
                farbe=Farbe.SCHWARZ;
            }
            if(maus1.hPosition()>=40 && maus1.hPosition()<=60 && maus1.vPosition()>=10 && maus1.vPosition()<=30){
                stift1.setzeFarbe(Farbe.ROT);
                farbe=Farbe.ROT;
            }
            if(maus1.hPosition()>=70 && maus1.hPosition()<=90 && maus1.vPosition()>=10 && maus1.vPosition()<=30){
                stift1.setzeFarbe(Farbe.GRUEN);
                farbe=Farbe.GRUEN;
            }
            if(maus1.hPosition()>=10 && maus1.hPosition()<=30 && maus1.vPosition()>=40 && maus1.vPosition()<=60){
                stift1.setzeFarbe(Farbe.GELB);
                farbe=Farbe.GELB;
            }
            if(maus1.hPosition()>=40 && maus1.hPosition()<=60 && maus1.vPosition()>=40 && maus1.vPosition()<=60){
                stift1.setzeFarbe(Farbe.BLAU);
                farbe=Farbe.BLAU;
            }
            if(maus1.hPosition()>=70 && maus1.hPosition()<=90 && maus1.vPosition()>=40 && maus1.vPosition()<=60){
                stift1.setzeFarbe(Farbe.ORANGE);
                farbe=Farbe.ORANGE;
            }
            if(maus1.hPosition()>=10 && maus1.hPosition()<=90 && maus1.vPosition()>=300 && maus1.vPosition()<=310){
                stift1.setzeLinienBreite(1);
            }
            if(maus1.hPosition()>=10 && maus1.hPosition()<=90 && maus1.vPosition()>=330 && maus1.vPosition()<=340){
                stift1.setzeLinienBreite(2);
            }
            if(maus1.hPosition()>=10 && maus1.hPosition()<=90 && maus1.vPosition()>=360 && maus1.vPosition()<=370){
                stift1.setzeLinienBreite(3);
            }
            if(maus1.hPosition()>=20 && maus1.hPosition()<=80 && maus1.vPosition()>=200 && maus1.vPosition()<=230){
                loeschen();
            }
            if(maus1.hPosition()>=20 && maus1.hPosition()<=80 && maus1.vPosition()>=240 && maus1.vPosition()<=270){
                rechteck();
            }
        }
    }
 
    public void loeschen(){
 
        for ( int line = 0; line <= bildschirm1.hoehe(); line++ ) {
            stift1.bewegeBis(101,line);
            stift1.setzeFarbe(Farbe.WEISS);
            stift1.runter();
            stift1.bewegeBis(bildschirm1.breite(),line);
            stift1.hoch();
        }
        stift1.setzeFarbe(farbe);
    }
 
    public void rechteck(){
 
        while(maus1.istGedrueckt()){
            System.out.println("bla");
        }
 
        while(!maus1.istGedrueckt()){
            System.out.println("bla");
        }
 
            // Gehen wir zu dem Punkt an dem die Maus ist
            stift1.hoch();
            stift1.bewegeBis(maus1.hPosition(),maus1.vPosition());
            stift1.zeichneKreis(1);
 
            int x1=maus1.hPosition();
            int y1=maus1.vPosition();
            // Und warten bis die Maus losgelassen wird
            while(maus1.istGedrueckt()){
                ;
                // ; // solange machen wir einfach garnichts und lasten nur den cpu ein wenig aus ;)
            }
            int x2=maus1.hPosition();
            int y2=maus1.vPosition();
            int x=x2-x1;
            int y=y2-y1;
            if(x>=0 && y>=0){
               stift1.zeichneRechteck(x,y);
            }else if(x>=0 && y<0){
               stift1.bewegeBis(x1,y2);
               stift1.zeichneRechteck(x,-y);
            }else if(x<0 && y>=0){
               stift1.bewegeBis(x2,y1);
               stift1.zeichneRechteck(-x,y);                    
            }else if(x<0 && y<0){
               stift1.bewegeBis(x2,y2);
               stift1.zeichneRechteck(-x,-y);                                        
            }
            stift1.bewegeBis(x2,y2);
            stift1.runter();
    }
 
    public void machmal(){
        // Interface bauen
        stift1.bewegeBis(100,0);
        stift1.runter();
        stift1.bewegeBis(100,bildschirm1.hoehe());
        stift1.hoch();
        stift1.setzeFuellMuster(Muster.GEFUELLT);
        // Schwarz
        stift1.setzeFarbe(Farbe.SCHWARZ);
        stift1.bewegeBis(10,10);
        stift1.zeichneRechteck(20,20);
        // Rot
        stift1.setzeFarbe(Farbe.ROT);
        stift1.bewegeBis(40,10);
        stift1.zeichneRechteck(20,20);
        // Gr�n
        stift1.setzeFarbe(Farbe.GRUEN);
        stift1.bewegeBis(70,10);
        stift1.zeichneRechteck(20,20);
        // Gelb
        stift1.setzeFarbe(Farbe.GELB);
        stift1.bewegeBis(10,40);
        stift1.zeichneRechteck(20,20);
        // Blau
        stift1.setzeFarbe(Farbe.BLAU);
        stift1.bewegeBis(40,40);
        stift1.zeichneRechteck(20,20);
        // Orange
        stift1.setzeFarbe(Farbe.ORANGE);
        stift1.bewegeBis(70,40);
        stift1.zeichneRechteck(20,20);
 
        // Löschen
        stift1.setzeFarbe(Farbe.SCHWARZ);
        stift1.setzeFuellMuster(Muster.DURCHSICHTIG);
        stift1.bewegeBis(20,200);
        stift1.zeichneRechteck(60,30);
        stift1.bewegeBis(30,220);
        stift1.schreibeText("Clear");
 
        // Rechteck
        stift1.setzeFarbe(Farbe.SCHWARZ);
        stift1.setzeFuellMuster(Muster.DURCHSICHTIG);
        stift1.bewegeBis(20,240);
        stift1.zeichneRechteck(60,30);
        stift1.bewegeBis(30,220);
 
        // Breiten
        stift1.setzeFarbe(Farbe.SCHWARZ);
        stift1.setzeFuellMuster(Muster.DURCHSICHTIG);
        stift1.bewegeBis(20,300);
        stift1.setzeLinienBreite(1);
        stift1.runter();
        stift1.bewegeBis(80,300);
        stift1.hoch();
        stift1.bewegeBis(10,295);
        stift1.zeichneRechteck(80,10);
 
        stift1.bewegeBis(20,330);
        stift1.setzeLinienBreite(2);
        stift1.runter();
        stift1.bewegeBis(80,330);
        stift1.hoch();
        stift1.bewegeBis(10,325);
        stift1.zeichneRechteck(80,10);
 
        stift1.bewegeBis(20,360);
        stift1.setzeLinienBreite(3);
        stift1.runter();
        stift1.bewegeBis(80,360);
        stift1.hoch();
        stift1.bewegeBis(10,355);
        stift1.zeichneRechteck(80,10);
 
        // Und los gehts :D
        stift1.setzeFarbe(Farbe.SCHWARZ);
        do {
            farbwechsel();
            if(maus1.istGedrueckt()){
                if(maus1.hPosition()>100){
                    stift1.bewegeBis(maus1.hPosition(),maus1.vPosition());
                }
                stift1.runter();
                stift1.zeichneKreis(0.1);
                while(maus1.istGedrueckt()){
                    farbwechsel();
                    if(maus1.hPosition()>100){
                        stift1.bewegeBis(maus1.hPosition(),maus1.vPosition());
                        stift1.runter();
                    }else{
                        stift1.hoch();
                    }
                }
                stift1.hoch();
            }
        } while(!maus1.doppelKlick());
        bildschirm1.gibFrei();
        maus1.gibFrei();
        stift1.gibFrei();
    }
 
    // Dienste
 
}

Themen zum Informatikunterricht in der Jahrgangsstufe 11

start/info/11if.txt · Zuletzt geändert: 23.10.2013 10:12 (Externe Bearbeitung)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0