Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View slashman's full-sized avatar

Santiago Zapata slashman

View GitHub Profile
@slashman
slashman / Display.js
Created August 10, 2018 13:11
Add torch-like effect to JSRL game
var LIGHT_COLOR = { r: 255, g: 128, b: 128 };
var LIGHT_INTENSITY = 0.7;
var MAX_DIST = 8;
// Helper function that calculates a distance
function distance(x1, y1, x2, y2) {
return Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}
// Helper function that does blending between two values
@slashman
slashman / ScrollingContainer.js
Last active February 25, 2024 10:02
PixiJS 4 Scrolling Container
/* globals TweenMax, Quad, Back, Elastic */
/*
* Original implementation: https://codepen.io/wiledal/pen/ZYoNEa?editors=0010
* Requires GreenSockss GSAP 2.0.1
* Works with PixiJS 4.7.3
*/
export default class ScrollContainer {
constructor(x, y, width, height, itemHeight) {
/**
* Pick the closest portal. If advancing to it puts you in danger, pick the less dangerous portal instead. If it's the same, or it
* still endangers you, there's no escape portal
*/
Enemy.prototype.getEscapePortal = function(){
console.log('getEscapePortal');
var portal = this.getClosestPortal();
if (!portal){
console.log('no closest portal');
* Add about 77 new weapon types
* New reloading mechanics for bows (Can only load one arrow at a time, quick reloading by passing turn). Also applies for crossbows and slings.
* Add Dagger, Whip, Scythe, Sling, Crossbow weapon types
* Prevent wand and liquid ammo from being parried
* Change starting equipment for Hunter (bow and sword)
* Add item modifiers (Fire and Smite Undead)
* Make most classes start with a befriend monster spell
* Give evolve potion on level 5
* Allow throwing pebbles
* Change number of enemies per level (independent of depth)
@slashman
slashman / gist:3c98a4c84510829efac3
Last active August 29, 2015 14:05
Ananias Player serialization
circular.registerClass('Player', Player, {
transients: {
gameController: true,
sprite: true
},
reviver: function(object, reviverData){
object.gameController = reviverData.gameController;
var gameController = object.gameController;
for (var i = 0; i < object.items.length; i++){
var item = object.items[i];
{"object":{"_c":{"type":"AnaniasGame","uid":158},"version":"1.22","player":{"type":"Player","uid":90}},"references":{"x158":{"_c":{"type":"AnaniasGame","uid":158},"version":"1.22","player":{"type":"Player","uid":90}},"x90":{"level":1,"hitPoints":{"type":"Stat","uid":88},"attack":{"type":"Stat","uid":89},"items":[{"type":"Item","uid":91},{"type":"Item","uid":94},{"type":"Item","uid":95}],"x":4,"y":3,"currentWeapon":{"type":"Item","uid":91},"currentArmor":{"type":"Item","uid":94},"carryCapacity":8,"knows":{"_c":{"isCircularSafe":true},"checkInventory":true},"isFriendly":true,"_c":{"type":"Player","uid":90},"facingLeft":true,"pet":{"type":"Enemy","uid":97},"dungeonLevel":{"type":"Level","uid":99},"currentRoom":{"type":"Room","uid":126},"itemAction":"USE"},"x88":{"max":40,"current":40,"_c":{"type":"Stat","uid":88}},"x89":{"max":3,"current":3,"_c":{"type":"Stat","uid":89}},"x91":{"code":"Quarterstaff","spriteIndex":384,"paperdollIndex":48,"name":"Quarterstaff","description":"Quarterstaff","onUse":"wield","_c":{"ty