Now I have a few questions because there are a lot bugs in my program.
So is in the third screen (state D) the button wrong. how can I fix that?
By state W there must be a random word for 0,9 sec but it isn't. And how can it appear left or right and not from 200 until 400?
An other problem is that in the textfield a person must typ the word that they saw before but how can I program that whhen it word is good there is a screen "the word is good' and when its wrong 'the word is wrong try again'.
Can someone help me?
import controlP5.*;
PFont fontA;
int rectX, rectY; // Position of square button
int circleX, circleY; // Position of circle button
int rectSizeh = 40; // Diameter of rect
int rectSizew = 100;
color rectColor, baseColor;
color rectHighlight;
color currentColor;
boolean rectOver = false;
String tekst1, tekst2;
char State;
int timeOffset;
float timeToNextk;
float timeToNextw;
float timeToNexte;
import controlP5.*;
ControlP5 controlP5;
String textValue = "";
Textfield myTextfield;
Woorden[] woorden = new Woorden[300];
/*
STATES:
E = Beginscherm --
B = Begin1 --
D = Begin2 --
K = Kruis --
W = Woord --
T = Antwoord --
G = Goed --
F = Fout --
N = einde --
*/
void setup() {
size(600, 600);
background(255);
timeToNextk = random (3000, 5000);
timeToNextw = (3000);
timeToNexte = (7000);
State = 'E';
}
void draw() {
if (State == 'E') {
background(255);
runWoordHerkenning();
for (int i = 0; i < 250; i = i +15 ) {
woorden[i] = new Woorden(random(width), random(height));
int index = int(random(words.length)); // same as int(random(6))
text(words[index], x, y);
}
}
void runWoordHerkenning() {
fontA = loadFont("Arial-BoldMT-40.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 40);
fill (110,90,255);
text("WoordherkenningsTest", 55, 300);
}
void drawknop()
{
rectColor = color(190,190,240);
rectHighlight = color(110,90,255);
baseColor = color(255);
currentColor = baseColor;
rectX = width/2-(rectSizew/2);
rectY = 500;
update(mouseX, mouseY);
if (rectOver) {
fill(rectHighlight);
}
else {
fill(rectColor);
}
stroke(0);
rect(rectX, rectY, rectSizew, rectSizeh);
fill(0); // black
text("Continue", rectX+10, rectY+25);
}
void update(int x, int y)
{
if ( overRect(rectX, rectY, rectSizew, rectSizeh) ) {
rectOver = true;
}
else {
rectOver = false;
}
}
boolean overRect(int x, int y, int width, int height)
{
if (mouseX >= x && mouseX <= x+width &&
mouseY >= y && mouseY <= y+height) {
return true;
}
else {
return false;
}
}
void displayKruis(float x, float y, float c) {
int w = 20;
int h = 100;
rectMode(CENTER);
fill (c);
rect(x, y, w, h);
rect(x, y, h, w);
fill(110,90,255);
ellipse(x, y, 10, 10);
rectMode(CORNERS);
}
// GLOBAL
int x = 30;
// FUNCTIONS
void runtekst() {
fontA = loadFont("Arial-BoldMT-16.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 16);
rectMode (CORNER);
tekst1 = "In het volgende experiment, word een kruis getoond. Daarna volgt een woord dat verschijnt aan de linker of rechterkant van het kruis. Het woord verschijnt snel. Als je het woord kan lezen,dan kan je daarna het woord typen. Als het woord te snel verschijnt dan druk op ENTER en probeer opnieuw. Elke keer wanneer het woord verschijnt, verschijnt het wat langer in beeld." ;
tekst2 = "Voor het onderzoek is het van belang dat je je ogen richt op het knipperende kruis.";
fill (0);
text(tekst1, x, 60, 500, 500);
}
void runtekst2() {
fontA = loadFont("Arial-BoldMT-16.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 16);
fill (0);
text("Voor het onderzoek is het van belang dat je je ogen richt op het knipperende kruis.", x, 60, 540, 400);
}
void runtekstantwoord() {
fontA = loadFont("Arial-BoldMT-16.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 16);
fill (0);
text("Hieronder kan je het woord invullen wat je net zag.", x, 140, 540, 400);
}
void runtekstgoed() {
fontA = loadFont("Arial-BoldMT-16.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 16);
fill (0, 225, 0);
text("Het woord is GOED. Druk op ENTER om naar de volgende te gaan.", x, 60, 540, 400);
}
void runtekstfout() {
fontA = loadFont("Arial-BoldMT-16.vlw");
// de font en de grootte van het lettertype
textFont(fontA, 16);
fill (225, 0, 0);
text("Het woord is FOUT. Druk op ENTER om het opnieuw te proberen.", x, 60, 540, 400);
I am really a beginner, but i want to learn programming. I have made a class, but he don't work. Can some one say what is wrong with it? I have look at al lot of tutorails but I really dont know.
// DECLARE
knopje mijnknopje;
void setup() {
size(600, 600);
// INITIATIE
mijnknopje = new knopje();
}
void draw() {
background(255);
// FUNCTIONALLITY
mijnknopjekruis.runknopje ; //don't work
}
class knopje {
// GLOBAL
float bx =250;
float by =450;
int knhoogte = 40;
int knbreedte = 100;
boolean over = false;
boolean locked = false;
float bdifx = 0.0;
float bdify = 0.0;
// CONSTRUCTORS
knopje (){}
// FUNCTIONS
void runknopje () {
drawknopje();
muisoverknopje ();
mousePressed();
}
void drawknopje (){ // button to go to the next page
fill (153); //gray
rect(bx, by, knbreedte, knhoogte);
fill(0); // black
text("Continue",bx+15,by+28);
}
void muisoverknopje (){
if (mouseX > bx-knbreedte && mouseX < bx+knbreedte &&
mouseY > by-knhoogte && mouseY < by+knhoogte) {
over = true;
if(!locked) {
stroke(0); //black
}
} else {
stroke(153); //gray
over = false;
}
}
// press the mouse button
void mousePressed() {
if(over) {
locked = true;
// it goes to the next page (I still have to program it)