Skip to content

Commit

Permalink
merge lvl 11
Browse files Browse the repository at this point in the history
  • Loading branch information
KennyLiang2302 committed May 20, 2023
2 parents d1d38b8 + a5ea342 commit f181fbd
Show file tree
Hide file tree
Showing 19 changed files with 846 additions and 148 deletions.
44 changes: 44 additions & 0 deletions assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,50 @@
}
}
},
"leaf1": {
"file": "images/objects/leaf1.png",
"wrap": false,
"sprites": {
"strip" : {
"size" : 15,
"rows" : 1,
"cols" : 15
}
}
},
"leaf2": {
"file": "images/objects/leaf2.png",
"wrap": false,
"sprites": {
"strip" : {
"size" : 15,
"rows" : 1,
"cols" : 15
}
}
},
"leaf3": {
"file": "images/objects/leaf3.png",
"wrap": false,
"sprites": {
"strip" : {
"size" : 15,
"rows" : 1,
"cols" : 15
}
}
},
"leaf4": {
"file": "images/objects/leaf4.png",
"wrap": false,
"sprites": {
"strip" : {
"size" : 15,
"rows" : 1,
"cols" : 15
}
}
},

"dust": "images/dust.png",
"werewolf": {
Expand Down
Binary file added assets/images/objects/leaf1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/objects/leaf2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/objects/leaf3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/objects/leaf4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/jsons/enemies.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"lockout": 0.3,
"hitbox": {
"range": 0.8,
"width": 1.5,
"width": 0.7,
"bullet": true,
"sensor": true
}
Expand Down
18 changes: 12 additions & 6 deletions assets/jsons/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@
"type": "circle",
"radius": 0.25
}
}
},
"leaves": "leaf1.strip"
},
"tree6": {
"textures": {
Expand All @@ -429,7 +430,8 @@
"type": "circle",
"radius": 0.275
}
}
},
"leaves": "leaf3.strip"
},
"tree7": {
"textures": {
Expand All @@ -445,7 +447,8 @@
"type": "circle",
"radius": 0.45
}
}
},
"leaves": "leaf2.strip"
},
"tree8": {
"textures": {
Expand Down Expand Up @@ -477,7 +480,8 @@
"type": "circle",
"radius": 0.45
}
}
},
"leaves": "leaf3.strip"
},
"tree10": {
"textures": {
Expand All @@ -493,7 +497,8 @@
"type": "circle",
"radius": 0.23
}
}
},
"leaves": "leaf4.strip"
},
"tree11": {
"textures": {
Expand All @@ -509,7 +514,8 @@
"type": "circle",
"radius": 0.35
}
}
},
"leaves": "leaf2.strip"
},

"tallgrass-1": {
Expand Down
5 changes: 4 additions & 1 deletion core/src/infinityx/lunarhaze/combat/PlayerAttackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import infinityx.lunarhaze.controllers.InputController;
import infinityx.lunarhaze.models.entity.Werewolf;

import static java.lang.Math.pow;

/**
* Handles all attacking for the player.
* The player additionally has a three-part combo attack system.
Expand Down Expand Up @@ -187,7 +189,8 @@ private void initiateDash(GameplayController.Phase phase) {

private void processDash(Vector2 direction, float delta) {
float t = dashTimer / DASH_TIME;
float impulse = MAX_IMPULSE * t;
// Cubic ease-in-out interpolation
float impulse = (float) (MAX_IMPULSE * (t < 0.5 ? 4*t*t*t : 1 - pow(-2*t + 2, 3) / 2));
entity.getBody().applyLinearImpulse(direction.x * impulse, direction.y * impulse, entity.getX(), entity.getY(), true);
dashTimer += delta;
if (dashTimer >= DASH_TIME) {
Expand Down
1 change: 0 additions & 1 deletion core/src/infinityx/lunarhaze/controllers/EnemyState.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ public void update(EnemyController entity) {
LOCKED_OUT() {
@Override
public void enter(EnemyController entity) {
System.out.println("locked out");
entity.getEnemy().setSteeringBehavior(null);
}

Expand Down
31 changes: 31 additions & 0 deletions core/src/infinityx/lunarhaze/graphics/GameCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,37 @@ public void draw(Texture image, float alpha, float ox, float oy,
draw(holder, alphaCache, ox, oy, x, y, angle, sx, sy);
}

/**
* Draws the tinted texture with the given transformations
* <p>
* The texture colors will be multiplied by the given color. This will turn
* any white into the given color. Other colors will be similarly affected.
* <p>
* The transformations are BEFORE after the global transform (@see begin(Affine2)).
* As a result, the specified texture origin will be applied to all transforms
* (both the local and global).
* <p>
* The local transformations in this method are applied in the following order:
* scaling, then rotation, then translation (e.g. placement at (sx,sy)).
*
* @param image The texture to draw
* @param alpha The alpha tint
* @param ox The x-coordinate of texture origin (in pixels)
* @param oy The y-coordinate of texture origin (in pixels)
* @param x The x-coordinate of the texture origin (on screen)
* @param y The y-coordinate of the texture origin (on screen)
* @param angle The rotation angle (in degrees) about the origin.
* @param sx The x-axis scaling factor
* @param sy The y-axis scaling factor
*/
public void draw(TextureRegion image, float alpha, float ox, float oy,
float x, float y, float angle, float sx, float sy) {
// Call the master drawing method (more efficient that base method)
holder.setRegion(image);
alphaCache.a = alpha;
draw(holder, alphaCache, ox, oy, x, y, angle, sx, sy);
}

/**
* Draws the texture at the given position.
* Unless otherwise transformed by the global transform (@see begin(Affine2)),
Expand Down
8 changes: 8 additions & 0 deletions core/src/infinityx/lunarhaze/models/Billboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.JsonValue;
import infinityx.assets.AssetDirectory;
Expand Down Expand Up @@ -45,11 +46,14 @@ public class Billboard implements Drawable {

public String name;

private Vector2 pos;

public Billboard(Vector3 position, float scale) {
this.position = position;
this.scale = scale;
this.tint = new Color(Color.WHITE);
this.animation = new Animation();
this.pos = new Vector2();
}

public void initialize(AssetDirectory directory, JsonValue json) {
Expand Down Expand Up @@ -113,6 +117,10 @@ public float getDepth() {
return position.y;
}

public Vector2 getPos() {
return pos.set(getPosition().x, getPosition().y + getPosition().z);
}

@Override
public void draw(GameCanvas canvas) {
FilmStrip curFrame = animation.getKeyFrame(Gdx.graphics.getDeltaTime());
Expand Down
7 changes: 7 additions & 0 deletions core/src/infinityx/lunarhaze/models/Dust.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import infinityx.lunarhaze.graphics.GameCanvas;
import infinityx.util.Drawable;
Expand Down Expand Up @@ -230,6 +231,12 @@ public void setFadeRange(float min, float max) {
fadeMax = max;
}

Vector2 pos = new Vector2();
@Override
public Vector2 getPos() {
return pos.set(getPosition().x, getPosition().y + getPosition().z * 3 / 4);
}

/**
* Once called this particle will begin decaying (disappearing) then become reset.
*/
Expand Down
5 changes: 5 additions & 0 deletions core/src/infinityx/lunarhaze/models/GameObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public GameObject() {
this(0, 0);
}

@Override
public Vector2 getPos() {
return getPosition();
}

/**
* Creates a new game object with degenerate collider settings.
* <p>
Expand Down
9 changes: 8 additions & 1 deletion core/src/infinityx/lunarhaze/models/LevelContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ public void removeSceneObject(SceneObject object) {
}
}
}
if (object.leaves != null) {
for (Leaf leaf : object.leaves) {
leaf.setDestroyed(true);
}
}
object.setActive(false);
}

Expand Down Expand Up @@ -675,7 +680,9 @@ public void drawLevel(float delta, GameCanvas canvas, boolean editor) {
// depth as the z-position so OpenGL's depth buffer can do all the work
drawables.sort(drawComp);
for (Drawable d : drawables) {
d.draw(canvas);
// Even more early clipping
if (editor || d.getPos().dst(player.getPos()) < 15)
d.draw(canvas);
}

// The scene objects rendered before the player (behind) should not become transparent
Expand Down
Loading

0 comments on commit f181fbd

Please sign in to comment.