I am really new to programming. For my class, I am making a game and I would like to add a seconds player to the game. At the moment, there are black circles that appear randomly in the game and keep growing. You are a circle and you need to avoid the circles for as long as possible. Once you intersect with one the game ends. This circle is controlled with the arrow keys. However I would like to add a new circle with the keys WASD. This is my code so far. But when the game starts I can see the circle but I cannot move it.
The main part of the code I am worried about is ProcessUserInput2 because that is the code that controls WASD. I have not pasted in my entire code. Any help would be much appreciated
void draw()
{
//Call functions
if (gameState == 0)//Start Screen
{
ProccessUserInput_Start(); //this function is in a separate tab. It processes what the player inputs into the computer, and then translates it into commands
Render_Start();
savedTime = millis();
}
if (gameState == 1)//Game Playing Screen
{
ProcessUserInput1(); //this is for the arrow keys
ProcessUserInput2(); //this is for WASD
Render();
totalTime = 40000; //Timer (in millis)
for (growingEllipse e:ellipses)
{
e.ellipseGrow();
e.rendering();
}
void ProcessUserInput1()
//Move circle Left, Right, Up or Down using arrow keys
{
if (keyPressed)
{
if (keyCode == LEFT)//Move Left
{
x1 = x1 - 2;
}
if (keyCode == RIGHT)//Move Right
{
x1 = x1 + 2;
}
if (keyCode == UP)//Move Up
{
y1 = y1 - 2;
}
if (keyCode == DOWN)//Move Down
{
y1 = y1 + 2;
}
}
}
void ProcessUserInput2()
//Move circle Left, Right, Up or Down using arrow keys
{
if (keyPressed)
{
if (keyCode == 'A')//Move Left
{
x2 = x2 - 2;
}
if (keyCode == 'D')//Move Right
{
x2 = x2 + 2;
}
if (keyCode == 'W')//Move Up
{
y2 = y2 - 2;
}
if (keyCode == 'S')//Move Down
{
y2 = y2 + 2;
}
}
}
void Render()
{
background(255);
fill(255, 228, 196);
ellipse (x1, y1, r1, r1);
ellipse (x2, y2, r1, r1);
//draw circle for player
}
If possible, could any really good programmers give me their email so that I can ask them questions? I still need to add in a few more items such as inheritance and function overloading. I used the Processing application for this.