我正在尝试旋转并根据三角形的指向方向将三角形移动到某个方向.理论上,我计算方向的正弦和余弦(0-360度)并将这些值加到x和y位置,对吗?它只是不起作用.
此外,三角形应该指向开头,而不是向下.
public void speedUp() {
float dirX, dirY;
speed *= acceleration;
if(speed > 50) speed = 50;
println("dir: " + direction + " x: " + cos(direction) + " y: " + sin(direction));
dirX = cos(direction);
dirY = sin(direction);
xPos+=dirX;
yPos+=dirY;
}
public void redraw() {
GL gl = pgl.beginGL(); // always use the GL object returned by beginGL
gl.glTranslatef(xPos, yPos, 0);
gl.glRotatef(direction, 0, 0, 1000);
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor4f(0.1, 0.9, 0.7, 0.8);
gl.glVertex3f(-10, -10, 0); // lower left vertex
gl.glVertex3f( …Run Code Online (Sandbox Code Playgroud) 每当我尝试添加一个country到我的ArrayList<country> 继续得到这个错误:unexpected token: (它突出我的countries.add线.我不确定为什么会这样.
class country {
private int mland, mwaters; //mtotalborders;
private String mcenter;
country(int earth, int aqua, String yn) {
mland = earth;
mwaters = aqua;
mcenter = yn;
}
public int getLand() {
return mland;
}
public int getWaters() {
return mwaters;
}
public int getTotalBorders() {
return mland+mwaters;
}
public String getCenter() {
return mcenter;
}
}
country Turkey = new country(16, 7, "No");
country France = new country(22, …Run Code Online (Sandbox Code Playgroud) 我在Processing(Java)中创建了以下草图:
ArrayList<Piece> pieces = new ArrayList<Piece>();
void setup() {
size(300, 300);
pieces.add(new Piece(100, 200)); // I ADD ONE PIECE TO THE ARRAY LIST
}
void draw() {
background(0);
for (int i = 0; i < pieces.size(); i++) {
Piece p = pieces.get(i);
p.display(); // I WANT TO DRAW THE PIECE I'VE CREATED IN SETUP()
}
}
class Piece {
int x;
int y;
Piece (int x, int y) {
x = x;
y = y;
}
void display() {
fill(255); …Run Code Online (Sandbox Code Playgroud) 当我在Processing中创建一个整数变量时,我应该使用int还是Integer?他们似乎都以同样的方式工作.它是可选的你会使用哪一个?
// The same thing?
int a = 5;
Integer b = 4;
// I prefer Integer because it looks like String:
Integer c = 95;
String d = "Hello!";
// Then again, int looks like char:
int e = 3;
char f = 'a';
Run Code Online (Sandbox Code Playgroud)
我认为它可能只是一个人喜欢的,虽然int使用更多?
在Java中,我想设置一个可以存储多个整数(RGB值)的变量,整数用逗号分隔.例如,我当前的代码就像
background(255,255,0); // This changes my GUI background color to yellow.
Run Code Online (Sandbox Code Playgroud)
我想要的代码是
type yellow = (Here goes the yellow's RGB value 255,255,0)
background(yellow);
Run Code Online (Sandbox Code Playgroud)
我的问题是如何设置变量黄色,以便它可以取代实际的RGB值.谢谢.
我正在使用java模式进行处理,如果我按照这样的正常方式制作条件,我想要超过32
If (-------- == --------){//dosomething}
Else If (-------- == --------){//dosomething}
Else If (-------- == --------){//dosomething}
Else If (-------- == --------){//dosomething}
Else If (-------- == --------){//dosomething}
Else {//dosomething}
Run Code Online (Sandbox Code Playgroud)
但只有第一个条件有效,其余条件不起作用有时它会给我错误"Eof"
我也试过这种风格
If (-------- == --------){//dosomething}
Else {//dosomething}
If (-------- == --------){//dosomething}
Else {//dosomething}
If (-------- == --------){//dosomething}
Else {//dosomething}
Run Code Online (Sandbox Code Playgroud)
它也不起作用只有第一个if条件工作
注意有一次gui没有显示按钮或标签
我怎么能回答这个问题,如果有条件我怎么写多少
这是一个例子,y1和y的值来自其他设备并且在我按下硬件按钮时改变1和0这个代码不完整但只有概念而且从y1到y20以及从x1到x20只有第一个条件这工作,我尝试所有的矩形
这是完整代码问题的更新
**在这段代码中我使用了17个按钮,如果按下它们就会读取它们,矩形颜色将是黑色,如果没有按下,矩形将是白色,它效果很好,但只有9个输入,但其余的17没有用,请注意我检查了所有输入和所有连接,它们运行良好,我怎么能解决这个问题**
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int x1 = 255;
int x2 = 255;
int x3 = 255;
int x4 = 255;
int x5 = 255;
int …Run Code Online (Sandbox Code Playgroud) 我是编程的初学者,我刚刚完成了一个使用Processing制作的Android游戏.但是,当我尝试获取应用程序的APK(导出签名包)时,我收到以下错误:
由于以下错误,无法创建密钥库:
构建文件夹:C:\ Users\User\AppData\Local\Temp\android5125294986448583924sketch setTestClassesDir(File)方法已被弃用,并计划在Gradle 5.0中删除.请改用setTestClassesDirs(FileCollection)方法.getTestClassesDir()方法已弃用,计划在Gradle 5.0中删除.请改用getTestClassesDirs()方法.不推荐使用ConfigurableReport.setDestination(Object)方法,并计划在Gradle 5.0中将其删除.请改用ConfigurableReport.setDestination(File)方法.
由于我是初学者,我完全不知道如何继续.
看到我为创建应用程序而浪费的所有努力真的很糟糕....
任何帮助是极大的赞赏!
Processing是一个创新的编码平台-语言,IDE和生态系统-由Processing社区在Processing Foundation https://processing.org的支持下维护。处理Java模式通常可以从Java库中的代码中受益。
JCSG是基于BSP的CSG(构造实体几何)的Java实现https://github.com/miho/JCSG。
首先,此函数是处理专用的还是默认情况下在Java中存在?
当我在处理下面的代码行时,
println(float("88") + "\t" + float("88\n") + "\t" + float("88p") ); // p is just an arbitrary character other than '\n'
Run Code Online (Sandbox Code Playgroud)
它输出
88.0 88.0 NaN
Run Code Online (Sandbox Code Playgroud)
那么,为什么float()函数可以在'\ n'字符下正常工作,而不能在'p'上工作呢?他们不是两个角色吗?我知道'\ n'很特殊,但是在这种情况下是否有所不同?
编辑:由于一些警告来自答案,所以我用“ p”替换了“ K”。
processing ×10
java ×7
android ×2
arraylist ×2
csg ×1
geometry ×1
gradle ×1
if-statement ×1
multi-touch ×1
opengl ×1
sdk ×1