Skip to content

Commit

Permalink
fix: fix items that don't collide like traps and pads
Browse files Browse the repository at this point in the history
  • Loading branch information
Picoseconds committed Aug 3, 2020
1 parent 025744d commit 89d0128
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/items/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ function getGameObjID(item: ItemType) {
return 0;
}

function hasCollision(item: ItemType) {
return items[item].group.layer >= 1;
}

function getWeaponSpeedMultiplier(weapon: Weapons) {
return weapons[weapon].spdMult || 1;
}

export { PrimaryWeapons, SecondaryWeapons, getHitTime, Weapons, getWeaponAttackDetails, getWeaponDamage, getItemCost, getPlaceable, getPlaceOffset, getScale, getGameObjID, getWeaponGatherAmount, getPrerequisiteItem, getGroupID, getPrerequisiteWeapon, getWeaponSpeedMultiplier };
export { PrimaryWeapons, SecondaryWeapons, getHitTime, Weapons, getWeaponAttackDetails, getWeaponDamage, getItemCost, getPlaceable, getPlaceOffset, getScale, getGameObjID, getWeaponGatherAmount, getPrerequisiteItem, getGroupID, getPrerequisiteWeapon, getWeaponSpeedMultiplier, hasCollision };
6 changes: 5 additions & 1 deletion src/moomoo/Physics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Player from "./Player";
import { eucDistance } from "./util";
import GameObject from '../gameobjects/GameObject';
import { gameObjectSizes } from "../gameobjects/gameobjects";
import { getWeaponAttackDetails, Weapons } from "../items/items";
import { getWeaponAttackDetails, Weapons, hasCollision } from "../items/items";
import GameState from "./GameState";

function collideCircles(pos1: Vec2, r1: number, pos2: Vec2, r2: number) {
Expand Down Expand Up @@ -38,6 +38,10 @@ function tryMovePlayer(player: Player, delta: number, xVel: number, yVel: number
);

for (let gameObj of player.getNearbyGameObjects(state)) {
if (!gameObj.type && typeof gameObj.data === 'number') {
if (!hasCollision(gameObj.data)) continue;
}

if (collidePlayerGameObject(player, gameObj)) {
xVel *= .75;
yVel *= .75;
Expand Down

0 comments on commit 89d0128

Please sign in to comment.