Ein Programm Wort Affe das an 10 verschieden positionen gezeichnet wird

Chillout1213

Mitglied
Hallo Leute,

ich bin ganz neu hier und hab ein furchtbar wichtiges anliegen ich muss für meine Aufnahme auf der FH ein kleines java Programm schreiben aber irgendwie komm ich nicht weiter vl könnt ihr mal reinschauen und mir sagen was ich anders machen muss. Bitte nicht zu kompliziert erklären bin in Sachen Java noch ein totaler Anfänger.

Code:
Java:
var my_canvas = document.getElementById("c");
var my_context = my_canvas.getContext("2d");

my_canvas.width = 250;
my_canvas.height = 250;


//
// Diese paar Zeilen zeichnen zwei Linien.
// bitte aus dem endgültigen Programm dann löschen
//


my_context.moveTo(0, 0);
my_context.lineTo(250, 20);

my_context.moveTo(100, 100);
my_context.lineTo(0, 20);
my_context.stroke();

//
// eine Funktion die ein A zeichnet
// als argumente: 
//    x1,y1 ist das linke obere Eck,
//    i ist die Zeilenhöhe.   

function a(x1, y1, i) {
    my_context.moveTo(x1, y1+i);
    my_context.lineTo(x1+i/2, y1);
    my_context.lineTo(x1+i, y1+i);
    my_context.moveTo(x1+i/4, y1+i/2);
    my_context.lineTo(x1+3*i/4, y1+i/2);
    my_context.stroke();
}
function f(x3, y3, i) {
    my_context.moveTo(x3, y3+i);
    my_context.lineTo(x3+i/2, y3);
    my_context.lineTo(x3+i, y3+i);
    my_context.moveTo(x3+i/4, y3+i/2);
    my_context.lineTo(x3+3*i/4, y3+i/2);
    my_context.stroke();
}
function f(x1, y1, i) {
    my_context.moveTo(x1, y1+i);
    my_context.lineTo(x1+i/2, y1);
    my_context.lineTo(x1+i, y1+i);
    my_context.moveTo(x1+i/4, y1+i/2);
    my_context.lineTo(x1+3*i/4, y1+i/2);
    my_context.stroke();
}
function e(x1, y1, i) {
    my_context.moveTo(x1, y1+i);
    my_context.lineTo(x1+i/2, y1);
    my_context.lineTo(x1+i, y1+i);
    my_context.moveTo(x1+i/4, y1+i/2);
    my_context.lineTo(x1+3*i/4, y1+i/2);
    my_context.stroke();
}



//
// zwei zufallszahlen zwischen 0 und 200 erzeugen
//

x_zufall=Math.random()*200;
y_zufall=Math.random()*200;

//
// a mit den zufalls-koordinaten aufrufen.
//

a(x_zufall,y_zufall,50);
f(x_zufall,y_zufall,70);
 

Neue Themen


Oben