fix error in __example_inventory

This commit is contained in:
Mitch Weaver
2017-11-26 00:44:25 +01:00
parent febe7b2e37
commit 20b40a071d
8 changed files with 46 additions and 6 deletions

7
.classpath Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="dep/jython-2.7.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/bin/

17
.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>sjgs</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>

View File

@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
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=1.8

View File

View File

@@ -22,6 +22,8 @@ class __InventoryExample extends Engine {
super(WIDTH, HEIGHT, title); super(WIDTH, HEIGHT, title);
} }
private static int WIDTH=800;
private static int HEIGHT=600;
// Create our engine! // Create our engine!
private static __InventoryExample engine; private static __InventoryExample engine;
// Create our inventory! // Create our inventory!
@@ -29,7 +31,7 @@ class __InventoryExample extends Engine {
// Create the window for our engine, and initialize our engine itself while we're here. // Create the window for our engine, and initialize our engine itself while we're here.
public static void main(final String[] args) { public static void main(final String[] args) {
engine = new __InventoryExample(800, 600, "Inventory System Demonstration"); engine = new __InventoryExample(WIDTH, HEIGHT, "Inventory System Demonstration");
} }
// Create our mouse input, which will also add itself to our engine that we're passing in. // Create our mouse input, which will also add itself to our engine that we're passing in.
@@ -96,8 +98,9 @@ class __InventoryExample extends Engine {
@Override @Override
public void init() { public void init() {
final int w = 50, h = 50; final int w = 50, h = 50;
for(int i = 1; i < 6; i++) slots.add(new ExampleInventorySlot(engine.getWidth() * 0.3f, engine.getHeight()*0.1f + i*h, w, h, i - 1));
for(int i = 1; i < 6; i++) slots.add(new ExampleInventorySlot(engine.getWidth() * 0.6f, engine.getHeight()*0.1f + i*h, w, h, i - 1)); for(int i = 1; i < 6; i++) slots.add(new ExampleInventorySlot(WIDTH * 0.3f, HEIGHT*0.1f + i*h, w, h, i - 1));
for(int i = 1; i < 6; i++) slots.add(new ExampleInventorySlot(WIDTH * 0.6f, HEIGHT*0.1f + i*h, w, h, i - 1));
// And fill them with random items // And fill them with random items
for(int i = 0; i < 10; i++) addItem(rand.nextInt(4)); for(int i = 0; i < 10; i++) addItem(rand.nextInt(4));

View File

@@ -36,8 +36,8 @@ class __PhysicsDemonstration extends Engine {
@Override @Override
protected void init() { protected void init() {
disableFpsCap(); //disableFpsCap();
setDoubleTickRate(); //setDoubleTickRate();
camera = new Camera(this); camera = new Camera(this);
new ExampleDevConsole(this); new ExampleDevConsole(this);
new ExampleMouseInput(this); new ExampleMouseInput(this);

View File

@@ -8,7 +8,7 @@ def __engine_onLeftClick(inventory):
for e in inventory.getSlots(): for e in inventory.getSlots():
# IF THE SECOND SLOT CONTAINS THE MOUSE POINTER, SWAP! # IF THE SECOND SLOT CONTAINS THE MOUSE POINTER, SWAP!
if i != e and e.bounds.contains(Mouse.getClickX(), Mouse.getClickY()): if i != e and e.bounds.contains(Mouse.getClickX(), Mouse.getClickY()):
inventory.swap(i, e) inventory.swapSlots(i, e)
return # NOTE: YOU MUST RETURN HERE OR IT WONT WORK! return # NOTE: YOU MUST RETURN HERE OR IT WONT WORK!
# GRAPHICAL SLOT MOVING! # GRAPHICAL SLOT MOVING!