Giter Site home page Giter Site logo

collinhover / impactplusplus Goto Github PK

View Code? Open in Web Editor NEW
277.0 277.0 59.0 12.51 MB

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.

Home Page: http://collinhover.github.com/impactplusplus

License: MIT License

CSS 1.19% JavaScript 98.81%

impactplusplus's Introduction

impactplusplus's People

Contributors

aroth avatar bdaenen avatar collinhover avatar lamphj avatar nakanaa avatar pattentrick avatar racingcow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

impactplusplus's Issues

EntityText not working?

I'm trying to spawn a EntityText using the following but it's not working...

ig.game.spawnEntity(EntityText, x, y, {
    text: 'hello',
});

I have tried setting the 'textDisplayed' property too to no avail.

What's going on?

Did the character initiate a jump?

I have a player entity that extends the impact++ playerEntity and I need to play a sound when the character initiates a jump.

I couldn't find a way to easily check whether he initiated a jump or not.

The only thing I have is the jumping property but that property stays true for the entirety of the jump.

I think the jump method on the playerEntity class should return true or false when initiating a jump, such that I can do :

jump: function() {
    if (this.parent()) {
        this.sound.jump.play();
    }
}

I have never issued a pull request before though so don't know how to do that :P

Colliding entities are not removed from layer's checking list properly.

It appears that sometimes when an entity that collides or checks is killed, it is not removed from a layer's checking list properly. If that same entity is then respawned, it will check collisions twice each update. Each respawn after that will continue adding another check to the update cycle. It may be best to handle removing from layers more conservatively, instead of trying to take shortcuts for performance.

Triggers should chain to other triggers.

Currently, triggers will only activate their targets. If one of these targets is a trigger, activating it will not trigger it, which stops the trigger chain. Triggers should chain to each other, but they should not chain infinitely.

Possibility to set margins on the canvas?

I wanted my canvas to be fullscreen (GAME_WIDTH_PCT = 1 & GAME_WIDTH_PCT = 1) but leave space for a 200px sidebar. For it, I added these to config-user.js:

"GAME_WIDTH_MARGIN": 200,
"GAME_HEIGHT_MARGIN": 0,

and edited core/game.js resize function:

var width = _c.GAME_WIDTH_PCT ? ig.global.innerWidth * _c.GAME_WIDTH_PCT - _c.GAME_WIDTH_MARGIN : _c.GAME_WIDTH;
var height = _c.GAME_HEIGHT_PCT ? ig.global.innerHeight * _c.GAME_HEIGHT_PCT - _c.GAME_HEIGHT_MARGIN : _c.GAME_HEIGHT;

I think this would be a good addition to Impact++ itself. Didn't make a pull request at least yet because I wasn't sure if you'd want this in.

ig.game.getEntitiesByClass forces area boundary

Hi, @collinhover. I think I may have discovered a bug, or at least a change in behavior that I don't quite know how to handle yet.

Since the new code on lines 1697-1705 of game.js was introduced in this commit, it looks like the behavior of ig.game.getEntitiesByClass has changed.

I used to be able to do something like this to get the first entity of type (class name, not type from plusplus type system) EntityClaribel...

var firstMatching = ig.game.getEntitiesByClass('EntityClaribel')[0];

...but after the change, it seems that I have to either send in settings for distanceSquared/from, or minX, minY, maxX, and maxY. If I don't, ig.game.getEntitiesByClass returns an empty array, and firstMatching from the code above is undefined.

If I try something like...

var matching = ig.game.getEntitiesByClass('EntityClaribel', { 
    distanceSquared: 100000,
    from: {x: 0, y: 0}
});
var firstMatching = matching[0];

... I get the entity I am looking for, but then in my specific case, the camera won't follow the main player (not sure why this happens yet).

Is this a bug, or am I just missing something?

collision box, offset and angle/rotation

So, I have a sword entity. Which has a size of 3x10. The sword itself is 3x10 (the animationSheet)

But when I rotate the entity, the collision box is not rotated nor is it sized up to accommodate.

What should I do?

Value of "scale" is undefined in image-drawing.js

In Image-drawing.js on line 129 x and y are both divided by "scale", but I can't seem to find where you define scale. I would issue a pull request, but with trial and error I have been unable to find what the value of scale should be.

I tried changing scale to "this.scale" which ran without errors, but gave very odd results when trying to view any images.

Pathfinding and slopes == bug?

It seems to me that one of my Characters are unable to jump up to a slope.
If I change that slope to a regular square block, it works fine. He jumps up.

Nothing ever collides

It looks like when refactoring to move ig.Entity.COLLIDES to ig.EntityExtended.COLLIDES, something was forgotten and now nothing collides.

Collisions occurring when one entity has collides never

Appears that the recent collision rework that moved collision solving into entities is allowing collisions between an entity pair where one has collides never and the other is collides active or fixed. The check for collides never was removed incorrectly.

ig.utilsvector2.pointsToConvexHull breaking in rare cases

Error and sample code provided by @Joncom:

var vertices = [{"x":-20,"y":28},{"x":-20,"y":20},{"x":-28,"y":20},{"x":-28,"y":12},{"x":-36,"y":12},{"x":-36,"y":4},{"x":-44,"y":4},{"x":-44,"y":-4},{"x":-52,"y":-4},{"x":-52,"y":-12},{"x":-84,"y":-12},{"x":-84,"y":-28},{"x":-52,"y":-28},{"x":-12,"y":12},{"x":12,"y":12},{"x":52,"y":-28},{"x":84,"y":-28},{"x":84,"y":-12},{"x":52,"y":-12},{"x":52,"y":-4},{"x":44,"y":-4},{"x":44,"y":4},{"x":36,"y":4},{"x":36,"y":12},{"x":28,"y":12},{"x":28,"y":20},{"x":20,"y":20},{"x":20,"y":28}];
ig.utilsvector2.pointsToConvexHull(vertices);

Event system?

So I'm writing a more complex AI system than I previously had.

I saw some stuff in the ++ code about 'signals'?
Is this an event system?

Anyway, what I want is to 'listen' or 'bind' to the ig.Character.moveToComplete method without overriding the method.

Is there a way to do so, and if not. I might look into writing an event system.. actually I think I already have a JS event system which I can hook into ++ easily.

EntityPlayer Regen properties are not persisting across player respawns

When an EntityPlayer dies and is respawned at a Checkpoint, the Regen properties are no longer in effect. The same effect is seen when Regen properties are set on a Player, then a new level is loaded via ig.loadLevelDeferred(). Once the new level is loaded, the regen is no longer active.

Slope Movement is buggy?

I have an entity that extends the Player entity.

I haven't done much customization yet and I notice when my character is moving DOWN on slopes, he falls on and off the slop constantly causing my dude to switch animation from running to falling rapidly.

This does not happen on regular impact entities, what's going on?

Remove 'control' on entity but let it be moved by other factors other than its own will?

So, i have an entity extending ig.Character and it has a stun method.

So when I stun it, I removeControl() on it, then addControl() after a while. But he freezes. He should still fall because of gravity and other factors etc. He should just not be able to do anything on its own.

Is there a way to remove 'movement' control on it only and still let it update?

UIMeter attempts to display nonexistent animation frame

I was making a health meter today, and I think I may have stumbled onto a bug. It looks like UIMeter will try and show an animation frame that is outside the bounds of the animSettings array.

In my case, I have created a UIMeterHealth class that extends ig.UIMeter. My meter references a sprite sheet that contains 12 images, each of 32x32px (3 across and 4 down), and has animSettings like so...

animSettings: {
    main: {
        sequence: [0,1,2,3,4,5,6,7,8,9,10,11]
    }
}

On the UIMeter.draw method (line 374), it calculates the current frame based on the length of the animation sequence and this.value. The value can range from 0 to 1, inclusive. Whenever it is anything from 0 to 12 - 1 = 11, everything is fine. When it nears the max health of the player, however, this.value becomes 1, and frame gets set to 12, which is outside of the bounds of the array.

Adding this line seemed to fix it for me. Let me know if a PR would help and I can send one.

if (frame == this.currentAnim.sequence.length) frame--;

zIndex not working?

So I have two entities, a player and a sword.

Sometimes I need the sword behind the player, so I do:

swordEntity.zIndex = -10;
ig.game.sortEntitiesDeffered();

But it doesn't seem to do anything, what am I missing?

BackgroundMap repeat make some bugs

Whena i set a background of 1x32 @32 with repeat property, i have this problem:

  • camera jumps
  • Background does not repeat well

When turning of repeat, all is fine.

Function `shapesFromCollisionMap` fails to produce hollow rectangles.

Test Case:

// main.js
ig.module('game.main')
.requires(
    'plusplus.helpers.utilstile',
    'impact.game'
)
.defines(function(){
    MyGame = ig.Game.extend({
        init: function() {
            var data = [
                [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
                [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
            ];
            var tilesize = 8;
            var collisionMap = new ig.CollisionMap(tilesize, data);
            var shapes = ig.utilstile.shapesFromCollisionMap(collisionMap);
            var solids = shapes.solids;
            for(var i=0; i<solids.length; i++) {
                var vertices = solids[i].settings.vertices;
                console.log(JSON.stringify(vertices));
            }
        }
    });
    ig.main( '#canvas', MyGame, 60, 320, 240, 2 );
});

Expected Output:
4 rectangles (1 top, 1 bottom, 1 left, and 1 right) which altogether form a hollow square.

Actual Output:
1 solid square, filled in where it should be hollow (screenshot).

[{"x":-56,"y":56},{"x":-56,"y":-56},{"x":56,"y":-56},{"x":56,"y":56}] 

Note:
This test case was done September 23, 2013 using the current dev branch.

Locking the camera inside the level

Currently there is no feature to lock the camera to the level. This is especially useful for top-down games, where getting to the edge of a level currently results into big black borders around the level.

UIInteractive - activate method not working with Ejecta

I am writing my code like this:

{

ig.UIButton = ig.UIInteractive.extend({

animSheet: new ig.AnimationSheet( 'media/shared/button_help.png', 52, 46 ),
animSettings: true,

activate: function ( entity ) {
    this.parent();
    console.log('*');
    // nothing happens when i click (touch) the button...
},

alwaysToggleActivate: true

});

MyGame = ig.GameExtended.extend({

init: function() {
    this.parent();

    var btn = this.spawnEntity(ig.UIButton,  10, (ig.system.height - 46 - 10));
},

update: function() {
    this.parent();

    ig.game.pause();
},

draw: function() {
    this.parent();
}

});

}

When i run this code on Ejecta and i click (touch) the button, nothing happens... I don't know if i am using it the wrong way or if it's not working properly... :)

Defer level and level asset loading until level first activated

@Vassildador brought up the idea of a deferred loading of level js file and assets until the level is first activated in #31. This would cut down initial load time greatly. Potentially instead of loading the next level when it is activated, we could search the level for level change trigger and preload that level? If none is found, we could either do nothing or preload all remaining levels while the player plays the first level?

jump velocity doubles when adding multiple player entities

I created two different player entities and set player2.controllable = false; player1 is not rendered to the canvas and neither entity is controllable. when setting player2.controllable = true; player 2 is rendered but the speed of movement is doubled for both grounded and ungrounded actions. it appears that multiple player entities cannot be on the same level.

Pixel positioning on linked UI Elements?

I have a question related to positioning UIElements.

I have a UIMenu linked to a UIHighlight (both extend UIElement),,,

ig.module(
        'mygame.ui.menu'
    )
    .requires(
        //...
    )
    .defines(function () {
        'use strict';

        ig.UIMenu = ig.global.UIMenu = ig.UIElement.extend({

            //...

            init: function(x, y, settings) {
                this.parent(x, y, settings);

                this.highlight = ig.game.spawnEntity(ig.Highlight, 0, 0, {
                    linkedTo: this,
                    zIndex: this.zIndex + 1,
                    name: 'highlight',
                    //some way to set pos.x/y relative to this.pos?
                });

            },

            //...

        });

    });

I want to be able to position UIHighlight a precise number of pixels away from UIMenu. It looks like once you have the two linked, you have to position the linked element using percentages and UIElement.linkAlign.

Is there some way to set the position of the linked element using pixels? Or is there some other easier way that I am missing?

Pathfinding broken?

I have an entity that should find it's path to a point in another room. It can only get there by climbing a ladder, which it does, but it doesn't go up all the way. Instead, it tries to move right into the platform it should be walking on.

This is the situation:
bildschirmfoto 2013-08-25 um 15 01 04

The entity basically gets stuck in that position, endlessly moving up and down a tiny bit.

AudioSource & AudioListener

I wanted to have certain sounds in the game sound as though they are further away, so I implemented two classes, ig.AudioSource and ig.AudioListener.

I could add this to plusplus and submit a pull request?

Consider a crate that plays a 'break' sound.

EntityCrate = ig.global.EntityCrate = ig.EntityExtended.extend({
    init: function() {
        this.audio = new ig.AudioSource();
        this.audio.sounds.break = new ig.Sound('path/to/sound.*');
        this.audio.suonds.break.volume = 0.5;
    },

    update: function() {
        this.parent();
        this.audio.pos.x = this.pos.x;
        this.audio.pos.y = this.pos.y;
    },

    break: function() {        
        //play sound
        this.audio.pos.x = this.pos.x;
        this.audio.pos.y = this.pos.y;
        this.audio.break.play();
    }
});

Now, you probably want to have the AudioListener at the camera's position.
So, in your game's init function:

init: function() {
    this.audiolistener = new ig.AudioListener();
},

update: function() {
    //update the position of the audiolistener
    this.audiolistener.pos.x = this.camera.pos.x;
    this.audiolistener.pos.y = this.camera.pos.y;
},

Notes

*You can still play sounds outside the context of the game world by simply playing ig.Sounds (not via an AudioSource object) for this like UI.
*You can set the radius of an AudioSource which determines how far away its sound will be heard.
*All sound objects still have a functional volume level. This is taken into account.
*I also have other improvements on the Sound class which allows for easy looping (via pause(), unPause() and continue() methods)
*I am investigating making use of the new WebAudio API to try and create panning for directional sound.

Explenation of the Type & Group system?

I'm reading the impact++ docs and I don't understand anything.

What are 'bitflags'? How do I add a type to my 'player' entity and my 'item' entity?

I need my player to check against 'items'. This is what I need, right?

Examples Needed for Advanced Features

If there is an advanced feature that does not yet have an example in either examples/jumpnrun or examples/supercollider, and you feel it is difficult to understand, please reply here and let me know. I've recently added a Impact++ SUPER COLLIDER! demo, which uses almost every single feature in the library, but it may not catch everything.

Please submit your requests as lists (even in the case of a single)

  • Pathfinding (done)
  • Pathfinding Maps (done)
  • Creature Prey / Predator (done)
  • Doors (done)
  • Checkpoints and Persistent Player (done)
  • UI Element (done)

'stop' and 'once' parameters specified in EntityExtended.animSettings are ignored

The stop or once parameters in animSettings are being ignored on an entities that extend ig.EntityExtended.

In the following entity, for example, the defaultAnim animation will repeat instead of playing once and then stopping.

ig.module(
        'game.entities.myentity'
    )
    .requires(
        'plusplus.core.config',
        'plusplus.core.entity',
        'plusplus.core.animation'
    )
    .defines(function () {

        var _c = ig.CONFIG;

        ig.MyEntity = ig.global.MyEntity = ig.EntityExtended.extend({            
            animSheet: new ig.AnimationSheet(_c.PATH_TO_MEDIA + 'myentity.png', 32, 32),
            animSettings: {                
                defaultAnim: {
                    frameTime: 0.1,
                    sequence: [0,1,2,1,0],                
                    once: true
                }
            }
        });
    });

I added a pull request #29. It should resolve this issue.

Moving a UIElement

Hi,

I'm a little unclear on how you move an UIElement, so here is my code

if(ig.input.pressed('popup')){
this.someEl = ig.game.spawnEntity(ig.UITextBox, 0, 0, {posPct: {x: 0, y: 0}, text: 'Hello!!!!!'});
this.someEl.moveToPosition({x: 100, y: 100});
}

is that the proper way to do that or am I missing a concept here because no matter what it always places it in the top left corner of the game window.

Creature Y Size and Wandering

Creatures with size Y greater than 16 seem to stop wandering. This can be replicated in the demo by changing the spike to have a size Y greater than 16.

I'm trying to look down in the creature wandering blocks to see what is causing this. I should note this is in the DEV branch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.