【发布时间】:2017-07-23 21:24:49
【问题描述】:
目前我正在尝试制作迷宫游戏。我只是试图加载精灵并让程序运行,但它无法正常工作并给我一条错误消息,说明: 用法:PApplet [选项] [草图参数] 有关说明,请参阅 PApplet 的 Javadoc。 我已经阅读了一些具有某种解决方案的答案,但是我不知道他们在说什么,因为我是一名 13 岁的初学者/中级程序员。这是给我错误消息的代码:
package MegaPackage;
import java.util.*;
import processing.core.PApplet;
import processing.core.PImage;
//Main method. Insert public variables and entities here.
public class FlatShooter extends PApplet {
PImage background;
PImage squareImage;
PImage life1Image;
PImage life2Image;
PImage life3Image;
PImage redEnemyImage;
public float xSpeedPlayer = 9;
public int score;
public int enemies;
public int lives;
public boolean moving = false;
public boolean moving2 = false;
public Square square;
public void setup(){
size(900, 900);
background=loadImage("background.jpeg");
squareImage=loadImage("player.png");
life1Image=loadImage("life.png");
life2Image=loadImage("life.png");
life3Image=loadImage("life.png");
square = new Square(squareImage, (width-100)/2, height * 4/5);
}
//Movement for player and other items
public void keyPressed(){
if( key == 'd' || key == 'D'){
moving = true;
}
if(key == 'a' || key == 'A'){
moving2 = true;
}
}
//Stopping movement for players and other items
public void keyReleased(){
if( key == 'd' || key == 'D'){
moving = false;
}
if(key == 'a' || key == 'A'){
moving2 = false;
}
}
public class Square{
PImage square;
float xPos;
float yPos;
public Square(PImage squareImage, float startX, float startY){
square=squareImage;
xPos=startX;
yPos=startY;
}
public void drawSquare(){
image(square, xPos, yPos);
}
}
public void move(float x, float y){
if(moving){
x += xSpeedPlayer;
}
if (moving2){
x-= xSpeedPlayer;
}
}
}
如果您可以用相当简单的术语和简单的解决方案给出这个答案,请这样做。谢谢。
【问题讨论】:
标签: java eclipse processing