Initial Commit
This commit is contained in:
parent
17e5e30d72
commit
0a85725d27
22 changed files with 348 additions and 0 deletions
6
pixels/.classpath
Normal file
6
pixels/.classpath
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
19
pixels/.idea/$PRODUCT_WORKSPACE_FILE$
generated
Normal file
19
pixels/.idea/$PRODUCT_WORKSPACE_FILE$
generated
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>11</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
6
pixels/.idea/misc.xml
generated
Normal file
6
pixels/.idea/misc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
pixels/.idea/modules.xml
generated
Normal file
8
pixels/.idea/modules.xml
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/pixels.iml" filepath="$PROJECT_DIR$/pixels.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
60
pixels/.idea/workspace.xml
generated
Normal file
60
pixels/.idea/workspace.xml
generated
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7c31da6a-66b0-444a-beb0-a06348f4758f" name="Default Changelist" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1Q1GQVN7ZYku37jOFJQNvjsr0Bd" />
|
||||
<component name="PropertiesComponent">
|
||||
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Init" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="bz.bronze.pixels.Init" />
|
||||
<module name="pixels" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="bz.bronze.pixels.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Application.Init" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="7c31da6a-66b0-444a-beb0-a06348f4758f" name="Default Changelist" comment="" />
|
||||
<created>1566930672613</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1566930672613</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
</project>
|
17
pixels/.project
Normal file
17
pixels/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<projectDescription>
|
||||
<name>pixels</name>
|
||||
<comment/>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
pixels/.settings/org.eclipse.jdt.core.prefs
Normal file
11
pixels/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=11
|
21
pixels/.vscode/launch.json
vendored
Normal file
21
pixels/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Debug (Launch) - Current File",
|
||||
"request": "launch",
|
||||
"mainClass": "${file}"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Debug (Launch)-Init<pixels>",
|
||||
"request": "launch",
|
||||
"mainClass": "bz.bronze.pixels.Init",
|
||||
"projectName": "pixels"
|
||||
}
|
||||
]
|
||||
}
|
17
pixels/bin/.project
Normal file
17
pixels/bin/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ge</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
BIN
pixels/bin/bz/bronze/pixels/Gameloop.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/Gameloop.class
Normal file
Binary file not shown.
BIN
pixels/bin/bz/bronze/pixels/Init.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/Init.class
Normal file
Binary file not shown.
BIN
pixels/bin/bz/bronze/pixels/Renderer.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/Renderer.class
Normal file
Binary file not shown.
BIN
pixels/bin/bz/bronze/pixels/Window.class
Normal file
BIN
pixels/bin/bz/bronze/pixels/Window.class
Normal file
Binary file not shown.
BIN
pixels/out/production/pixels/bz/bronze/pixels/Gameloop.class
Normal file
BIN
pixels/out/production/pixels/bz/bronze/pixels/Gameloop.class
Normal file
Binary file not shown.
BIN
pixels/out/production/pixels/bz/bronze/pixels/Init.class
Normal file
BIN
pixels/out/production/pixels/bz/bronze/pixels/Init.class
Normal file
Binary file not shown.
BIN
pixels/out/production/pixels/bz/bronze/pixels/Renderer.class
Normal file
BIN
pixels/out/production/pixels/bz/bronze/pixels/Renderer.class
Normal file
Binary file not shown.
BIN
pixels/out/production/pixels/bz/bronze/pixels/Window.class
Normal file
BIN
pixels/out/production/pixels/bz/bronze/pixels/Window.class
Normal file
Binary file not shown.
11
pixels/pixels.iml
Normal file
11
pixels/pixels.iml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
80
pixels/src/bz/bronze/pixels/Gameloop.java
Normal file
80
pixels/src/bz/bronze/pixels/Gameloop.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package bz.bronze.pixels;
|
||||
|
||||
public class Gameloop implements Runnable {
|
||||
|
||||
private Thread thread;
|
||||
private Renderer renderer;
|
||||
|
||||
private boolean running = false;
|
||||
private final double TPS = 1.0/60.0;
|
||||
|
||||
public void start() {
|
||||
renderer = new Renderer();
|
||||
|
||||
thread = new Thread(this);
|
||||
thread.run();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
running = true;
|
||||
|
||||
boolean render = false;
|
||||
|
||||
double firstTime = 0;
|
||||
double lastTime = System.nanoTime() / 1000000000.0;
|
||||
double passedTime = 0;
|
||||
double unprocessedTime = 0;
|
||||
|
||||
double tickTime = 0;
|
||||
int ticks = 0;
|
||||
int tps = 0;
|
||||
|
||||
while (running) {
|
||||
render = false;
|
||||
|
||||
firstTime = System.nanoTime() / 1000000000.0;
|
||||
passedTime = firstTime - lastTime;
|
||||
lastTime = firstTime;
|
||||
|
||||
unprocessedTime += passedTime;
|
||||
tickTime += passedTime;
|
||||
|
||||
while (unprocessedTime >= TPS) {
|
||||
unprocessedTime -= TPS;
|
||||
|
||||
render = true;
|
||||
|
||||
if (tickTime >= 1.0) {
|
||||
tickTime = 0;
|
||||
tps = ticks;
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
System.out.println("TPS: " + tps);
|
||||
}
|
||||
|
||||
if (render) {
|
||||
renderer.clear();
|
||||
|
||||
Window.update();
|
||||
ticks++;
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
}
|
23
pixels/src/bz/bronze/pixels/Init.java
Normal file
23
pixels/src/bz/bronze/pixels/Init.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package bz.bronze.pixels;
|
||||
|
||||
public class Init {
|
||||
|
||||
static Window window = new Window();
|
||||
static Gameloop game = new Gameloop();
|
||||
|
||||
public static void print(String out) {
|
||||
System.out.println(out);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
window.create();
|
||||
game.start();
|
||||
|
||||
print("Window Initialized!");
|
||||
print("Gameloop Started!");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
init();
|
||||
}
|
||||
}
|
20
pixels/src/bz/bronze/pixels/Renderer.java
Normal file
20
pixels/src/bz/bronze/pixels/Renderer.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package bz.bronze.pixels;
|
||||
|
||||
import java.awt.image.DataBufferInt;
|
||||
|
||||
public class Renderer {
|
||||
private int pW, pH;
|
||||
private int[] p;
|
||||
|
||||
public Renderer() {
|
||||
pW = Window.width;
|
||||
pH = Window.height;
|
||||
p = ((DataBufferInt)Window.pixels.getRaster().getDataBuffer()).getData();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
p[i] += i;
|
||||
}
|
||||
}
|
||||
}
|
49
pixels/src/bz/bronze/pixels/Window.java
Normal file
49
pixels/src/bz/bronze/pixels/Window.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package bz.bronze.pixels;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferStrategy;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class Window {
|
||||
static JFrame window = new JFrame();
|
||||
|
||||
static int width = 800;
|
||||
static int height = 600;
|
||||
static int scale = 1;
|
||||
static String title = "pixels | v0.01";
|
||||
|
||||
static BufferedImage pixels = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
static Canvas viewport = new Canvas();
|
||||
static BufferStrategy bs;
|
||||
static Graphics g;
|
||||
|
||||
public static void update() {
|
||||
g.drawImage(pixels, 0, 0, width, height, null);
|
||||
bs.show();
|
||||
}
|
||||
|
||||
public void create() {
|
||||
window.setSize(width, height);
|
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
window.setLayout(new BorderLayout());
|
||||
window.add(viewport, BorderLayout.CENTER);
|
||||
window.setResizable(false);
|
||||
window.setLocationRelativeTo(null);
|
||||
window.setTitle(title);
|
||||
window.setVisible(true);
|
||||
|
||||
Dimension s = new Dimension(width * scale, height * scale);
|
||||
viewport.setPreferredSize(s);
|
||||
viewport.setMaximumSize(s);
|
||||
viewport.setMinimumSize(s);
|
||||
|
||||
viewport.createBufferStrategy(2);
|
||||
bs = viewport.getBufferStrategy();
|
||||
g = bs.getDrawGraphics();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue