Skip to content

Commit

Permalink
Project more engine-like + code cleanup
Browse files Browse the repository at this point in the history
1) Removed multiple missuses of PApplet pass, due to it not needing to
be passed at that specific time.
2) Changed PreInit and init to setup the main application but also allow
for any changes by an overriding app (such as a game) to be taken into
account
  • Loading branch information
DemiKnight committed Nov 20, 2018
1 parent 33848b6 commit 96049f4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ gradle-app.setting

lib/

src/main/java/com.krytpicalknight.processingMe.test/
/src/main/java/com/krypticalKnight/testApp/
11 changes: 11 additions & 0 deletions src/main/java/com/krytpicalknight/processingMe/EntityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.krytpicalknight.processingMe.render.RenderManager;
import com.krytpicalknight.processingMe.render.ResourceManager;
import com.krytpicalknight.processingMe.render.ResourceRequirements;
import processing.core.PApplet;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -29,10 +30,12 @@ public class EntityManager {

private ResourceManager resourceM;

// private PApplet parent;

public EntityManager(RenderManager renderM, ResourceManager resourceManager)
{
this.renderManager = renderM;
// this.parent = P;
this.resourceM = resourceManager;

entityList = new LinkedList<>();
Expand All @@ -51,6 +54,14 @@ public void registerResource()
}
}

public void giveParentInstance(PApplet PA)
{
for (Entity entitySelected:entityList)
{
entitySelected.setParentProcessing(PA);
}
}

public void addToRegistry(Entity entToAdd)
{
entityList.add(entToAdd);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.krytpicalknight.processingMe;

import processing.core.PApplet;

/**
* When a game/application wants to register their Entities, implementing this will then allow the
* Entity Manager to use the class.
Expand Down
34 changes: 15 additions & 19 deletions src/main/java/com/krytpicalknight/processingMe/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,43 @@
import processing.core.PApplet;
import com.krytpicalknight.processingMe.render.RenderManager;
import com.krytpicalknight.processingMe.render.ResourceManager;
import com.krytpicalknight.processingMe.test.TestEntity;
import com.krypticalKnight.testApp.entities.TestEntity;

public class MainApp extends PApplet{

private static String version = "0.0.4";

// private com.krytpicalknight.processingMe.ConfigManager configM = new com.krytpicalknight.processingMe.ConfigManager();

private static RenderManager renderM;
private static EntityManager entityM;
private static ResourceManager resourceM;
private static PApplet instance;
protected static RenderManager renderM;
protected static EntityManager entityM;
protected static ResourceManager resourceM;
private PApplet instance;


public static void main(String[] args)
{
resourceM = new ResourceManager(instance);
renderM = new RenderManager(resourceM);
entityM = new EntityManager(renderM,resourceM);
PApplet.main("com.krytpicalknight.processingMe.MainApp");
}

private void preInit()
public void preInit()
{
// System.out.println("Pre-init started");
instance = this;

TestEntity test1 = new TestEntity(this);

entityM.addToRegistry(test1,true);

// System.out.println("Pre-Init ended");
resourceM = new ResourceManager();
renderM = new RenderManager(resourceM);
entityM = new EntityManager(renderM,resourceM);
}

private void init()
public void init()
{
// System.out.println("Init Started");
entityM.registerResource();
entityM.giveParentInstance(this);

}

public void postInit()
{
//WIP
}

public void settings()
Expand All @@ -60,7 +57,6 @@ public void setup()
public void draw()
{
renderM.clear(this);

renderM.renderFrame();
}

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/krytpicalknight/processingMe/render/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ public Entity(PApplet P)
this.parent = P;
}

/**
* Will be used when the parent Processing instance is set later on.
*/
public Entity()
{

}

public void setParentProcessing(PApplet p)
{
this.parent = p;
}

/**
* The x Location of the entity
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.krytpicalknight.processingMe.render;

import com.krytpicalknight.processingMe.MainApp;
import processing.core.PApplet;
import processing.core.PImage;
import processing.core.PShape;
Expand Down Expand Up @@ -38,15 +39,14 @@ enum supportedTypes{
/**
* LInk to the parent processing instance.
*/
private PApplet parent;
// private PApplet parent;

/**
*
* @param PAppletP A link to the parent processing instance.
*/
public ResourceManager(PApplet PAppletP)
public ResourceManager()
{
this.parent = PAppletP;
// this.parent = PAppletP;

this.shapeList = new LinkedList<>();
this.imageList = new LinkedList<>();
Expand Down

This file was deleted.

0 comments on commit 96049f4

Please sign in to comment.