id
stringlengths
36
36
text
stringlengths
1
1.25M
799a72f8-52a6-4ce1-8a12-1be6baf9f88c
public PlayState(int StateID) { super(); GameStateID = StateID; }
49aba354-6401-4fed-a71b-3e81a4ecf4c1
@Override public int getID() { return GameStateID; }
6c7889bf-033f-4235-8161-7c57e5c2c60b
@Override public void enter(GameContainer container, StateBasedGame game) throws SlickException { super.enter(container, game); if (!container.isMusicOn()) { if (music != null) { music.stop(); } } else { music = ResourceManager.getInstance().getMusic("horror_tale"); if (music != null) { mu...
430cb192-caeb-45a4-937c-38782e9617fc
@Override public void leave(GameContainer container, StateBasedGame game) throws SlickException { super.leave(container, game); if (container.isMusicOn()) { if (music != null && music.playing()) music.stop(); } }
a017120c-14de-47a7-8222-c3a0ab9cf3a5
public void init(GameContainer container, StateBasedGame game) throws SlickException { container.setVSync(vsyncOn); container.setShowFPS(!vsyncOn); container.setIcons(ICON_REF_ARRAY); // load tiled map //map = new BlockMap("data/level01.tmx"); // map = new BlockMap("data/testKarte.tmx"); map = new Bl...
6d0f53c9-9b7e-476a-94ca-ebda32572c63
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_ESCAPE)) { container.exit(); } /** DEBUG-MODE CHECK INPUT */ if (container.getInput().isKeyPressed(Input.KEY_F2)) { disregardCollisions =...
6287c4d9-1f2a-4b02-8bff-ea2dd333edb1
private boolean handleInput(Input input, int delta) throws SlickException { boolean playerHasMoved = false; playerOne.setStanding(true); float playerX = playerOne.getPosition().x; float playerY = playerOne.getPosition().y; Polygon playerPoly = playerOne.getBoundingPolygon(); if (input.isKeyDown(Input...
512e3927-e110-4359-9e7d-f1f594817f4d
public boolean entityCollisionWith(Polygon polygon) throws SlickException { for (Block entity : BlockMap.collisionBlockList) { if (polygon.intersects(entity.poly)) { return true; } } for (RotatableObject rotO : BlockMap.rotatableObjectList) { if(polygon.intersects(rotO.getShape())) { r...
2166aad7-e960-4b4d-a545-49fc6ddbb789
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // draw background image g.fillRect(0.0f, 0.0f, container.getWidth(), container.getHeight()); //background.draw(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); //in the render()-method camera.drawMap(); ...
d61d3856-ff6f-42ee-9bb8-57df71940bf2
public ArrayList<String>[] getCustomizablesListArray() { return customizablesListArray; }
ed4ed25c-6224-4eb6-ba37-75183b333fc0
private ResourceManager(){ soundMap = new HashMap<String, Sound>(); musicMap = new HashMap<String, Music>(); imageMap = new HashMap<String, Image>(); textMap = new HashMap<String, String>(); animationMap = new HashMap<String, Animation>(); for (int i=0; i<6; ++i) { customizablesListArray[i] = ...
140ca9d0-3e71-416a-92a2-bd1109623598
public final static ResourceManager getInstance(){ return _instance; }
40685591-4827-4983-9e37-cd2a11fa1f9a
public void loadResources(InputStream is) throws SlickException { loadResources(is, false); }
8c5587f2-2b5e-4f9e-9068-2270b3ad66b8
public void loadResources(InputStream is, boolean deferred) throws SlickException { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = null; try { docBuilder = docBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { ...
95248c1c-617a-4fba-a524-746fbf0dbecb
private void addElementAsText(Element resourceElement) throws SlickException{ loadText(resourceElement.getAttribute("id"), resourceElement.getTextContent()); }
f67f1873-39d8-4a2d-8ebe-58a2586f806f
public String loadText(String id, String value) throws SlickException{ if(value == null) throw new SlickException("Text resource [" + id + "] has invalid value"); textMap.put(id, value); return value; }
5f385bbb-9d2f-441d-a85c-df028e72d81f
public String getText(String ID) { return textMap.get(ID); }
7b64fec3-c5fc-4e18-a22f-e13784af8824
private void addElementAsSound(Element resourceElement) throws SlickException { loadSound(resourceElement.getAttribute("id"), resourceElement.getTextContent()); }
db8f232e-cc66-4dba-b5c1-668e732118c3
public Sound loadSound(String id, String path) throws SlickException{ if(path == null || path.length() == 0) throw new SlickException("Sound resource [" + id + "] has invalid path"); Sound sound = null; try { sound = new Sound(path); } catch (SlickException e) { throw new SlickException("Could not ...
67b6fbd0-fe88-449c-83df-674c64330fec
public final Sound getSound(String ID){ return soundMap.get(ID); }
fa8e13eb-5d81-4ed7-b551-d040ba1b7299
private void addElementAsMusic(Element resourceElement) throws SlickException { loadMusic(resourceElement.getAttribute("id"), resourceElement.getTextContent()); }
2c92e895-903d-448e-a826-b917336a8280
public Music loadMusic(String id, String path) throws SlickException{ if(path == null || path.length() == 0) throw new SlickException("Music resource [" + id + "] has invalid path"); Music music = null; try { music = new Music(path); } catch (SlickException e) { throw new SlickException("Could not ...
3ae215c1-4435-41ee-8f73-42f43fc7a0a1
public final Music getMusic(String ID){ return musicMap.get(ID); }
2a8fbcd8-6b7e-477c-aa22-20c9afadbf5f
private void addElementAsAnimation(Element resourceElement, String type) throws SlickException{ loadAnimation(resourceElement.getAttribute("id"), resourceElement.getTextContent(), Integer.valueOf(resourceElement.getAttribute("tw")), Integer.valueOf(resourceElement.getAttribute("th")), Integer.valueOf(res...
de405a12-f98c-4378-a0af-a1a888e286e9
private void loadAnimation(String id, String spriteSheetPath, int tw, int th, int duration, boolean flipped, String type) throws SlickException{ // type is declared after the slash "/" within resources.xml if(spriteSheetPath == null || spriteSheetPath.length() == 0) throw new SlickException("Image resource ["...
5f348410-b1e7-4892-8572-e05464eec0be
private final void addElementAsImage(Element resourceElement, String type) throws SlickException { loadImage(resourceElement.getAttribute("id"), resourceElement.getTextContent(), type); }
167908f5-7bcd-4f00-acff-346380c079f1
public Image loadImage(String id, String path, String type) throws SlickException{ if(path == null || path.length() == 0) throw new SlickException("Image resource [" + id + "] has invalid path"); Image image = null; try{ image = new Image(path); } catch (SlickException e) { throw new SlickException("...
ddafd95d-bfaa-44f0-bb43-4ced85fa40ee
public final Image getImage(String ID){ return imageMap.get(ID); }
1c64c5ff-2d93-49d3-9c1e-573849f92845
private final void insertImageIdIntoCorrespondingList(String id, String type) { if(type.endsWith("bg")){ customizablesListArray[0].add(id); }else if(type.endsWith("border")){ customizablesListArray[1].add(id); }else if(type.endsWith("brick")){ customizablesListArray[2].add(id); }else if(type.endsWith("...
467fb82c-ef71-4b25-b968-7619283d40f1
public SideScrollerGame(String title) { super(title); this.addState(new LoadingScreenState(LOADING_SCREEN_STATEID)); this.addState(new CreditsScreenState(CREDITS_SCREEN_STATEID)); this.addState(new PlayState(PLAY_STATEID)); this.enterState(LOADING_SCREEN_STATEID); }
186e305f-48c1-4c57-9a40-31d15b807371
@Override public void initStatesList(GameContainer container) throws SlickException { this.getState(LOADING_SCREEN_STATEID).init(container, this); this.getState(CREDITS_SCREEN_STATEID).init(container, this); this.getState(PLAY_STATEID).init(container, this); }
1f6cc816-20b8-4f90-a0d9-711a3cbb8058
public static void main(String[] args) throws SlickException { AppGameContainer app = new AppGameContainer(new SideScrollerGame(GAME_TITLE)); app.setVSync(WAIT_FOR_VSYNC); app.setSmoothDeltas(true); app.setTargetFrameRate(60); app.setShowFPS(false); app.setUpdateOnlyWhenVisible(true); app.setMusicOn(MU...
23d7f4ff-efe7-4a8a-a92c-9e07d9ffb8dd
public Game() { super(GAME_TITLE); }
81423bfa-f41a-43c5-8786-454f4a223ded
public void init(GameContainer container) throws SlickException { container.setVSync(vsyncOn); container.setShowFPS(!vsyncOn); container.setIcons(ICON_REF_ARRAY); // load tiled map //map = new BlockMap("data/level01.tmx"); // map = new BlockMap("data/testKarte.tmx"); map = new BlockMap("data/map/Karte_p...
1e731398-eef4-4b1e-ab7d-ef9fc2bbe6b0
public void update(GameContainer container, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_ESCAPE)) { container.exit(); } /** DEBUG-MODE CHECK INPUT */ if (container.getInput().isKeyPressed(Input.KEY_F2)) { disregardCollisions = !disregardCollisions; } if (co...
20f0b83b-a849-4d9f-a03f-6b947a1946af
private boolean handleInput(Input input, int delta) throws SlickException { boolean playerHasMoved = false; playerOne.setStanding(true); float playerX = playerOne.getPosition().x; float playerY = playerOne.getPosition().y; Polygon playerPoly = playerOne.getBoundingPolygon(); if (input.isKeyDown(Input...
839259bc-8f65-4b91-92cf-009d6c378ee3
public boolean entityCollisionWith(Polygon polygon) throws SlickException { for (Block entity : BlockMap.collisionBlockList) { if (polygon.intersects(entity.poly)) { return true; } } for (RotatableObject rotO : BlockMap.rotatableObjectList) { if(polygon.intersects(rotO.getShape())) { r...
36a363c3-5ded-4de9-a405-5564cd3073cf
public void render(GameContainer container, Graphics g) { // draw background image g.fillRect(0.0f, 0.0f, container.getWidth(), container.getHeight()); //background.draw(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); //in the render()-method camera.drawMap(); // draw information overlay if (playerOne.isWithinH...
10caafa4-b8e9-4e31-94d9-504482aa10ae
public static void main(String[] argv) throws SlickException { AppGameContainer container = new AppGameContainer(new Game(), SCREEN_WIDTH, SCREEN_HEIGHT, false); container.start(); }
e33da940-33ca-4135-ae3e-318b2195b3f1
public ColorBucket(String sheetRef, String overlaySheetRef, int[] cycles, int tileWidth, int tileHeigth, boolean flipped, Vector2f position, Color color) { super(null, color); this.position = position; this.color = color; // initialize Animation array for (int i = 0; i < bucket.length; ++i) { bucket[i...
1cd5dcce-9f44-45e4-8604-cae6d983837d
@Override public void update(long delta) { bucket[0].update(delta); bucket[1].update(delta); }
ab7c1714-7064-4d98-8356-ea3e9a4433d0
@Override public void draw(Graphics g) { bucket[0].draw(this.position.x, this.position.y); bucket[1].draw(this.position.x, this.position.y, color); }
88d6023d-222c-47b4-ac33-53cd94dbb053
public Color getColor() { return color; }
6af7046f-2579-4d59-a86c-13a3dd527a66
public HotButton(String baseImageRef, String overlayImageRef, Vector2f position, Color color, String triggeredEntity) { super(null, color); isPressed = false; this.position = position; try { if (triggeredEntity != null) { this.triggeredEntity = triggeredEntity; } else { throw new Slic...
3b19040d-daf0-4a1a-85ca-9ef1f32940ba
@Override public void update(long delta) { // TODO Auto-generated method stub }
6cf7e3ac-0c6c-4ce5-85f2-ce3a90c5c2f4
@Override public void draw(Graphics g) { if ((button[0] != null) && (button[1] != null)) { g.drawImage(button[0], position.x, position.y); g.drawImage(button[1], position.x, position.y, color); } else { g.draw(shape); } }
6938c8bc-96e0-4222-b9f6-1e6b12f926f0
public boolean isPressed() { return this.isPressed; }
603ceb80-d02e-41cd-836f-22aefe1800c7
public void press() { if (!isPressed) { isPressed = true; //search for triggered Entity.... } }
f63f5c91-07c9-4bfd-8273-4fe2316f9108
public StaticSprite(String imageRef, Vector2f position, Color color) { super(null, color); this.position = position; this.color = color; try { this.image = new Image(imageRef); this.shape = new Rectangle(this.position.x, this.position.y, this.image.getWidth(), this.image.getHeight()); } catch (SlickE...
b382b9c4-9e7a-4539-b3de-01e643441de2
@Override public void update(long delta) { }
33de9939-07ef-4e32-88a1-67c39c52d334
@Override public void draw(Graphics g) { if (image != null) { g.drawImage(image, position.x, position.y); } else { g.draw(shape); } }
00f2cc6c-3a6f-4292-953d-7f0613737469
public RotatableObject(Shape s, Color color, float pivotX, float pivotY, float acceleration, MovementDirection direction, String triggeredBy) { super(s, color); isRotating = false; angle = 0.0f; this.acceleration = acceleration; this.direction = direction; this.triggeredBy = triggeredBy; if ((pivotX >=...
5400b03c-825f-43aa-ad4c-3c62298819fb
@Override public void update(long delta) { if (isRotating) { angle = (angle + delta * acceleration) / 360.0f; if (direction.equals(MovementDirection.RIGHT)) { shape = shape.transform(Transform.createRotateTransform(-angle, pivotPoint.x, pivotPoint.y)); } else if(direction.equals(MovementDirectio...
0c62c2c1-4fd8-423a-8a3b-14b7b4eede0a
public void startRotation() { isRotating = true; }
61b6667a-da3a-4afe-9bdb-d07388c79ac2
public void stopRotation() { isRotating = false; }
e9ed6a69-026e-45c7-bc18-9dc722a856e1
public Enemy(Shape s) { super(s, new Color(0xAA, 0x00, 0x7F)); }
4a56c8e2-515d-46aa-aeb6-d4221cf35b9b
public Enemy(float[] points) { this(new Polygon(points)); }
3e69711b-f9c8-4426-93ad-abbb9d8dc3af
@Override public void update(long delta) { // TODO Auto-generated method stub }
a9b1a401-de89-44e4-b328-09b2429cc397
public MoveableObject(Shape s, Vector2f minPosition, Vector2f maxPosition, float acceleration, MovementDirection initialDirection) { super(s, new Color(0xFF, 0x00, 0x00)); this.minPosition = new Vector2f(minPosition); this.maxPosition = new Vector2f(maxPosition); this.acceleration = acceleration; direction...
a1d12a15-344b-487d-8107-37fe2220f6bd
@Override public void update(long delta) { if (direction.equals(MovementDirection.RIGHT)) { shape.setX(shape.getX() + acceleration * delta); if (shape.getX() > maxPosition.x) { shape.setX(maxPosition.x); direction = MovementDirection.LEFT; } } else if (direction.equals(MovementDirection.LE...
beb51a77-0161-4c3a-9674-b1286d80ca20
public GameObject(Shape s, Color color) { super(); this.shape = s; this.color = color; if (this.shape != null) { this.shapeFill = new GradientFill( s.getX(), s.getY(), Color.lightGray, s.getMaxX(), s.getMaxY(), color); } };
a03ad538-0e01-44d1-a3cc-77053bd9666a
public abstract void update (long delta);
6a9bf541-d918-458b-b56b-b1ec196913f2
public void draw(Graphics g) { if (this.shape != null) { g.fill(shape, shapeFill); g.draw(shape, shapeFill); } }
815336fa-0b02-4a04-9f20-4fa1d785f64b
public Color getColor() { return color; }
3d5f0712-6799-49c6-b4b3-115f95fabdd8
public Shape getShape() { return shape; }
8f1a2fa1-8b1b-44a7-9e25-5fdcc858107c
public Block(int x, int y, int test[], String type) { poly = new Polygon(new float[]{ x+test[0], y+test[1], x+test[2], y+test[3], x+test[4], y+test[5], x+test[6], y+test[7], }); }
f92f4233-f3d5-4c78-9c75-8b26af6b8d2b
public void update(int delta) { }
05a08a2c-e1e7-455a-bc66-59f55b057d94
public void translate(float cameraX, float cameraY) { poly.setLocation(poly.getX() + cameraX, poly.getY() + cameraY); }
83ef3342-c095-49ea-afde-87bfa0c3fd2f
public void draw(Graphics g) { g.draw(poly); }
5a7c75fc-abf8-4e27-af21-ed41b1c1153e
public static Vector2f getPlayerStart() { return playerStartVector; }
5e5495c0-5b97-447d-9ee2-3a4ba9faac21
public static Integer[] getVisibleLayers() { return visibleLayers.clone(); }
2999b0b1-c66e-4658-b6a0-78ecb449b595
public BlockMap(String ref) throws SlickException { // ArrayList initializations collisionBlockList = new ArrayList<Block>(); hotButtonList = new ArrayList<HotButton>(); colorBucketList = new ArrayList<ColorBucket>(); rotatableObjectList = new ArrayList<RotatableObject>(); moveableObjectList = n...
7051e2b4-037e-44d5-9900-9938eba9c922
public Raytracer(int width, int height) { this.height = height; this.width = width; }
36ee0c73-d03d-470b-97e6-c863ff7a2954
public void raytrace(Camera camera, Scene scene, String path) { String filename = path + "/Documents/BHfT/Computergrafik II/Uebung 1/" + "RaytracerImage.png"; new ImageGenerator(new RaytracerImage(camera, scene), width, height, filename, "png"); ImageGenerator.showImage(filename); }
109a6e0d-672d-4386-a57f-488331e669b7
public RaytracerImage(Camera camera, Scene scene) { this.camera = camera; this.scene = scene; }
95edb326-d10d-425c-93ba-425c31674045
@Override public Color pixelColorAt(int x, int y, int resolutionX, int resolutionY) { Ray generateRay = camera.generateRay(x, y, resolutionX, resolutionY); Hit intersect = scene.intersect(generateRay); if (intersect == null) { // Hintergrundfarbe - schwarz return new Color(0, 0, 0); } else { return...
451b306c-1c1b-46b3-bb5a-2b17cf8f5ad2
public Hit(Vector hitPoint, Color color) { this.hitPoint = hitPoint; this.color = color; }
28ec86bc-8db1-49ad-ae62-56a309ec4893
public Vector getHitPoint() { return hitPoint; }
f59ea303-be82-4e35-9bb0-a72d52e93179
public Color getColor() { return color; }
ff043d85-c5d4-4aea-a0f6-68448192397b
public Ray(Vector origin, Vector direction) { this.origin = origin; this.direction = direction; }
4fcc26bf-2f1c-4312-8d80-e3f48831941e
public Vector getOrigin() { return origin; }
0dc210a6-7da8-4777-bec0-3b3095a5df22
public Vector getNormalizedDirection() { return direction.normalize(); }
0c087208-5038-434f-9eb1-23ecae5741ab
public Vector getPoint(float t) { return origin.add(direction.mult(t)); }
f7b91aea-4c7f-47a8-b038-9672eda3ad8f
public Scene() { this.shapeList = new ArrayList<AbstractShape>(); }
171cf4b7-88cc-4933-b01c-c37dabd98927
public void addShape(AbstractShape shape) { shapeList.add(shape); }
04e20d4c-fc78-47fc-9dd6-74921f8d08a2
public Hit intersect(Ray ray) { ArrayList<AbstractShape> sortedList = new ArrayList<AbstractShape>(); for (AbstractShape shapes : sortedList) { if (shapes.intersect(ray) != null) { return shapes.intersect(ray); } } return null; }
5f068bd9-92c3-4823-9430-fbbf01b41dbf
public Sphere(Vector center, float radius, Color color) { this.center = center; this.radius = radius; this.color = color; }
588a4c6d-8d90-4bbf-8990-4bfa7d86f0a2
@Override public Hit intersect(Ray ray) { Vector x0 = ray.getOrigin().sub(center); Vector d = ray.getNormalizedDirection(); float t1 = 0.0f; float t2 = 0.0f; if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius * radius)) < 0) { return null; } if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius...
19d57c1f-37d6-48ae-b509-a4d6e8a7cd3c
public Plane(Vector normal, float distance, Color color) { this.normal = normal; this.distance = distance; this.color = color; }
a296f1a5-3df3-40e0-b2a7-75ea8288ff1f
@Override public Hit intersect(Ray ray) { // AnkerPunkt auf der Ebene Vector anchorPoint = ray.getOrigin(); Vector direction = ray.getNormalizedDirection(); float t = 0.0f; // ray parallel zur plane? if (normal.dot(direction) == 0) { return null; } else { t = ((distance - normal.dot(anchorPoint)...
5e001f24-fe72-4cd5-b920-36fc31b28432
public abstract Hit intersect(Ray ray);
32564bbc-7d9f-4972-904d-b30d0625df20
public Color(float r, float g, float b) { this.r = r; this.g = g; this.b = b; }
cdd3aafc-3f25-44af-91ee-750b0dcd9b3d
public Color(Vector v) { r = v.x; g = v.y; b = v.z; }
ef895e0f-39b0-438c-8d35-2986a6627423
public Color(float r, float g, float b, float a) { this.r = r; this.g = g; this.b = b; }
0b6fb7c4-990e-4d00-b9be-219b48c325ab
public boolean isBlack() { return r == 0.0 && g == 0.0 && b == 0.0; }
3c674f55-8868-4a2e-8bbc-95b08e0a7e58
public Color add(Color c) { return new Color(r + c.r, g + c.g, b + c.b); }
348995c3-878a-498a-ae88-dd77350aeb2b
public Color modulate(float s) { return new Color(r * s, g * s, b * s); }
190c87d7-9088-4c30-b53d-34c880c7ae80
public Color modulate(Color c) { return new Color(r * c.r, g * c.g, b * c.b); }
87e66e55-30d8-4a6d-baf2-c1c5d6dff565
public Color clip() { Color c = new Color(Math.min(r, 1), Math.min(g, 1), Math.min(b, 1)); return new Color(Math.max(c.r, 0), Math.max(c.g, 0), Math.max(c.b, 0)); }
4f7ca846-bc35-4541-9b8a-8369ad8f424c
public float[] asArray() { float[] v = { r, g, b }; return v; }