/* Variablendeklaration */
var Visibility; // Button
var img; // image
var xWidth = 150; // halbe Spielfeldbreite in m
var yHeight = 120; // halbe Spielfeldhöhe
var polygonWidth = 200; // Breite des Image und des Polygons
...
function setup()
{
...
// Laden der Konturdaten in das array "fileData", loadStrings()
// in pBasics_v0.2.js deklariert
loadStrings('data/contour.txt', loadStringFromFile, loadError);
img = loadImage('data/tschuri.png');
...
}
function draw()
{
...
imageMode(CENTER);
push();
translate(xi0, yi0);
image(img, 0, 0);
img.resize(polygonWidth*M, 0);
pop();
if (START)
{
...
numberOfWaypoints = floor((dataLength - 7)/2);
createWay(); // Erstinitialisierung Kontur
...
}
else
{
/************************ Berechnung der Bewegung *****************************************/
...
if (Visibility.drawButton()) drawWay(numberOfWaypoints);
...
}
}
function createWay()
{
for (var i = 0; i < numberOfWaypoints; i++)
{ // Kontur von file 'data/contour.txt' einlesen und entnormieren
wayPoints[i] = createVector(fileData[2*i+7]*polygonWidth, fileData[2*i+8]*polygonWidth);
}
...
}
function drawWay(numberOfWaypoints)
{ // Zeichnen der Kontur
...
beginShape();
vertex(kXi(wayPoints[0].x*M), kYi(wayPoints[0].y*M));
for (m = 1; m < numberOfWaypoints; m++)
{
vertex(kXi(wayPoints[m].x*M), kYi(wayPoints[m].y*M));
}
endShape();
}