Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset Loader #10

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions projects/SotF/res/Testmap.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="42" height="31" tilewidth="24" tileheight="24">
<tileset firstgid="1" name="Testset" tilewidth="24" tileheight="24">
<image source="tileset_1.png" width="96" height="96"/>
</tileset>
<layer name="Kachelebene 1" width="42" height="31">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAC+3OsQEAERQFwe9IHPpv19PFBhtMPq2qFtwXMw7c79MnmE+fZD59kvn0SebTJ5lPn2Q+fZK9Z48NN+ICF2DsjFgUAAA=
</data>
</layer>
</map>
Binary file added projects/SotF/res/tileset_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions projects/SotF/src/de/fhtrier/gdw2/sotf/AssetLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package de.fhtrier.gdw2.sotf;

import java.util.ArrayList;
import java.util.HashMap;

import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
import org.newdawn.slick.Animation;
import org.newdawn.slick.Image;
import org.newdawn.slick.tiled.TiledMap;

import de.fhtrier.gdw2.sotf.Interfaces.ITeam;
public class AssetLoader {

ArrayList<Sound> sounds = new ArrayList<Sound>();
ArrayList<Image> images = new ArrayList<Image>();
ArrayList<Animation> animations = new ArrayList<Animation>();
HashMap<Integer, String> maps = new HashMap<Integer, String>(10);
TiledMap map;

public AssetLoader() {
initializeAssets();

}

private void initializeAssets(){
maps.put(0, "Testmap.tmx");
}

public Sound getCollideSound(){
return null;
}

public Sound getEatingSound(){
return null;
}
/**
*
* L�dt eine Map und gibt sie zur�ck.
* @author <Torsten Scholer>
* @param stage - der index des levels
*/
public TiledMap loadMap(int stage) throws SlickException{
map = new TiledMap("res/" + maps.get(stage) , "res/");
return map;
}

public Image getCharacter(ITeam team){
return null;
}
}
7 changes: 6 additions & 1 deletion projects/SotF/src/de/fhtrier/gdw2/sotf/Game/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.newdawn.slick.SlickException;
import org.newdawn.slick.tiled.TiledMap;

import de.fhtrier.gdw2.sotf.AssetLoader;
import de.fhtrier.gdw2.sotf.Interfaces.IEatable;
import de.fhtrier.gdw2.sotf.Interfaces.IEntity;
import de.fhtrier.gdw2.sotf.Interfaces.IPlayer;
Expand All @@ -22,17 +23,21 @@ public class World {
private ArrayList<IEatable> eatables;
private ArrayList<IUseable> useables;
private ArrayList<IEntity> entitys;
AssetLoader assetLoader;

private TiledMap map;

/**
* Erstellt eine neue Welt
* @throws SlickException
*/
public World() {
public World() throws SlickException {
players = new ArrayList<IPlayer>();
eatables = new ArrayList<IEatable>();
useables = new ArrayList<IUseable>();
entitys = new ArrayList<IEntity>();
assetLoader= new AssetLoader();
map=assetLoader.loadMap(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static void main(String[] args)
try
{
AppGameContainer app = new AppGameContainer(new SlickTestGameState());
app.setDisplayMode(1024, 768, false);
app.start();
}
catch (SlickException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import de.fhtrier.gdw2.sotf.Game.World;

public class GameplayState extends BasicGameState
{

// Default State ID Wert -1;
int stateID = -1;
World world;

/**
* Konstruktor
Expand All @@ -32,7 +35,7 @@ public GameplayState(int stateID)
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException
{
// TODO Auto-generated method stub

world = new World();
}

@Override
Expand All @@ -45,6 +48,7 @@ public void render(GameContainer arg0, StateBasedGame arg1, Graphics arg2) throw
{
// TODO Auto-generated method stub
arg2.setBackground(Color.blue);
world.render(arg0, arg2);

}

Expand Down