我正在致力于将我的开源粒子引擎测试从 SDL 移植到 SDL + OpenGL。我已经成功地编译并运行了它,但无论我做什么,屏幕都保持黑屏。主要.cpp:
#include "glengine.h"
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
//Create a glengine instance
ultragl::glengine *gle = new ultragl::glengine();
if(gle->init())
gle->run();
else
std::cout << "glengine initializiation failed!" << std::endl;
//If we can't initialize, or the lesson has quit we delete the instance
delete gle;
return 0;
};
Run Code Online (Sandbox Code Playgroud)
glengine.h:
//we need to include window first because GLee needs to be included before GL.h
#include "window.h"
#include <math.h> // Math Library …Run Code Online (Sandbox Code Playgroud) 好吧,我正在尝试基于角度为0. x的原始位置旋转Java多边形,并且y最终在使用它们时最终转换为int,所以我可以理解没有看到一些变化,但是当角度差异大到0到180我觉得我应该看到一些东西.
我已经在这一段时间了,不能想到它是什么.这是方法.(对不起,如果它在代码标签中混乱,我的Firefox会搞砸它们.)
public void rotate(double x, double y, obj o1)
{
double dist = Math.sqrt(Math.pow(x - (o1.x + (o1.w/2)), 2) + Math.pow(y - (o1.y + (o1.h/2)),2));
x += (Math.sin(Math.toRadians(o1.a)) * dist);
y -= (Math.cos(Math.toRadians(o1.a)) * dist);
}
Run Code Online (Sandbox Code Playgroud) 我正试着让文字在我的网页上的小图像上浮动,我已经尝试了我能想到的一切.我会在这里嵌入html和css,但是我很难做到这一点,对不起.
(我会在回答时编辑网址,因此我不会将其用作广告.)[已删除]
由于某种原因,我的服务器停止在我的代码的标记区域中运行,我无法弄清楚原因.
import java.net.*;
import java.io.*;
public class SlickServer{
public static void main(String[] args) throws IOException {
int MAX_PLAYERS = 3;
int playerNum = 0;
Player[] players = new Player[MAX_PLAYERS];
players[0] = new Player(25,25);
players[1] = new Player(125,125);
players[2] = new Player(225,225);
ServerSocket serverSocket = new ServerSocket(40);
boolean listening = true;
while(listening){
System.out.println("Waiting to connect with: " + playerNum);
new ClientThread(serverSocket.accept(), players, playerNum).start();
//stops here.
System.out.println("Connected with: " + playerNum + " Now incrementing");
playerNum++;
System.out.println("Incremented to: " + playerNum);
} …Run Code Online (Sandbox Code Playgroud) 好的,所以这个bug花了我很多时间和尴尬.似乎任何带有 - 的名称的样式变量都不能被javascript修改.
如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Class Test</title>
<meta charset="utf-8" />
<style>
body { text-align: center; background-color: #ffffff;}
#box { position: absolute; left: 610px; top: 80px; height: 50px; width: 50px; background-color: #ff0000; color: #000000;}
</style>
<script type="text/javascript">
var box = 0;
</script>
</head>
<body>
<div id="box" ></div>
<script type="text/javascript">
box = document.getElementById('box');
box.style.background-color = "#0000ff";
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所述示例中的框将保持红色.
那么如何用 - 的名字改变一个样式变量呢?
好吧,所以我正在尝试制作一个快速而肮脏的平台引擎,我在碰撞检测和移动平台方面遇到了一些问题.一方面,"玩家"似乎在移动平台上稍微反弹,当他击中右侧时,错误也会发生.我将上传一个jnlp演示,以便您可以尝试查找更多错误并查看发生了什么,但这里是源代码:
import java.awt.Rectangle;
import java.util.Vector;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
public class Platformer extends BasicGame{
boolean keys[];
int ALL_KEYS = 0xFF;
Player player;
Vector<Vector<Thing> > things;
int level = 0;
public Platformer() {
super("You've met with a terrible fate, haven't you?");
}
public void init(GameContainer gc) throws SlickException {
keys = new boolean[ALL_KEYS];
for(int i = 0; i < ALL_KEYS; i++){
keys[i] = false;
}
player = new Player();
things = …Run Code Online (Sandbox Code Playgroud)