我對編程真的很陌生。對於我的班級,我正在製作一款遊戲,並且我想在遊戲中添加一名秒針玩家。目前,在遊戲中隨機出現黑色圓圈並保持增長。你是一個圈子,你需要儘可能避免圈子。一旦你與一個遊戲相交,遊戲就結束了。這個圓圈由箭頭鍵控制。不過,我想用鑰匙WASD添加一個新的圓。這是我的代碼到目前爲止。但是當遊戲開始時,我可以看到這個圈子,但我無法移動它。用鑰匙添加新玩家WASD
我擔心的代碼的主要部分是ProcessUserInput2,因爲那是控制WASD的代碼。我沒有粘貼我的整個代碼。任何幫助,將不勝感激
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
}
如果可能的話,可以在任何真正優秀的程序員給我他們的電子郵件,這樣我可以問他們問題?我仍然需要添加幾個項目,例如繼承和函數重載。我爲此使用了處理應用程序。
nottice你只捕捉'caps' char – 2014-12-03 10:45:44