Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by vassildador

@collinhover: I've been taking a short break but am back for more! :) The gamepad API is far from mature enough to make it worth the hassle so far, so I'll drop that idea for now :(

- I was thinking a bit more about a better way to handle asynchronous loading which would take more into account than just tileset images. It wouldn't be too hard to load entities based on what level to load (as all entities used are in the level files) and maybe we could extend Weltmeister with an extra pane to manually require more entities (for ones that are dynamically spawned)? These could be appended as a JSON string near the end of the level file without breaking compatibility with standard impact levels. The ones globally used could still be put in the game's "requires" section to be preloaded. What do you think :)?

- I'd like to have a go at location-aware sound effects (stereo). If the sound API supports balance adjustments by default (I'll have to look into this) it shouldn't be too hard and it'll end up with a really nice effect I think :). If the audio api in impact doesn't quite cut it I'll look into optionally using the native web audio api of the browser, if supported, to enhance the sound.

I'll keep you updated on my progress throughout the week ^^

1 decade ago by collinhover

@vassildador welcome back!

For async loading and stability, I think we need some way to hook into the core ImpactJS module require pattern. Perhaps that is what you are suggesting? If we do that, we don't need to load images, as they are already handled through the module require, but we still need to know when modules are loaded. Any idea how we could do that? The idea of giving the option to manually require entities that may be dynamically spawned is interesting, but if we are going to spawn dynamically, shouldn't we be requiring those entities in the spawner?

Sound is one thing I've not really delved into much, though I have been told that the browser audio api can only handle 1 sound at a time on some browsers. I don't want to include flash to fix that issue, but I think location-aware sound effects are really important for a game. 2D should make that quite easy!

1 decade ago by vassildador

@collinhover thanks :)

I'm afraid in order to hook into that we can't go around hacking impact itself, can we?

I've just quickly looked into impact audio and it's very basic. The web audio API on the other hand looks amazing. I'll see what I can do with it, the API isn't very widely supported yet but there's probably some way to provide a fallback to standard impact sound for Internet Explorer and some older Firefox versions :)

1 decade ago by collinhover

@vassildador in case you missed it, you might be interested in https://github.com/collinhover/impactplusplus/issues/77

1 decade ago by vicman4

Hi collinhover,

I'm new to Impactjs and Impact++. I'm developing a little game on Impact and i'm trying to move it to Impact++, but I'm having some issues:

- I've got three animSheet in my player's entity and can't figure out how to do it in impact++. Is there a way to set on animSettings from wich animSheet is every animation?

- Impact++ hadles movements and animations if they have the correct name (moveX, jumpLeft... etc). What's the right way to add custom animations like 'prone' or 'push'?

PS: Where's the right place to ask questions about impact++?

1 decade ago by collinhover

@vicman4 probably the best place to ask questions is via github issues or to ping me on twitter. I only check back here every few days.

To answer your question, You might want to check out the docs for the ig.Character abstract, there is an example that explains some of this: http://collinhover.github.io/impactplusplus/ig.Character.html (edit: the actual setting of animations in the example is incorrect right now, see the code below)

For a more specific answer, ig.Character does automatic animation switching based on the character status in the updateCurrentAnim method. It does not switch animation sheets or have any option to set what animation sheet an animation is from (all are assumed to be from the base animSheet property). This is something you would need to add yourself by overriding the updateCurrentAnim method (don't forget to call or block the parent call). Animations are created for an entity in the addAnim method so you can also override that and choose your animation sheet there by checking the settings passed (second parameter to the function).

To give you an example of all of this for the 'prone' animation (untested code):
var myGame = ig.GameExtended.extend({
	
	inputStart: function () {
		
		this.parent();
		
		ig.input.bind(ig.KEY.CTRL, 'ctrl');
		
	}
	
	// don't forget your init method override 
	
});

var myPlayer = ig.Player.extend({

    // use animSettings to add all your animations
    // including prone, push, etc
    animSettings: {
        ...
        prone: {
            sequence: [ 0 ],
            frameTime: 1
        }
        ...
    },

    // also update the expected animations with your custom ones
    animsExpected: [ ...,"prone", "push", ... ],
	
    prone: false,

    handleInput: function () {
		
		if ( ig.input.released( 'ctrl' ) ) {
			
			this.prone = !this.prone;
			
		}
		
		this.parent();
		
    },
	
    updateCurrentAnim: function () {
		
		if ( this.prone ) {
			
			this.currentAnim = this.anims[ this.getDirectionalAnimName( "prone" ) ];
			
		}
		else {
		
			this.parent();
			
		}
		
	}

});

1 decade ago by vicman4

Hi again @collinhover,

thank you very much for your time and atention!

I've finally managed to get it working as you said.

I've added a new property to each anim in animSettings (animSheet) and if it is present addAnim uses it instead of entity's animSheet:

        animSheet: new ig.AnimationSheet( _c.PATH_TO_MEDIA + 'player/Stand.png', 30, 30),
        runAnimSheet: new ig.AnimationSheet( _c.PATH_TO_MEDIA + 'player/Run.png', 30, 30),
	animSettings: {
			idleLeft: {
				frameTime: 0.2,
				sequence: [2,3,4,5,6]
			},
			idleRight: {
				frameTime: 0.2,
				sequence: [8,9,10,11,12]
			},
		        moveLeft: {
                                animSheet: "runAnimSheet",
				frameTime: 0.06, 
				sequence: [2,3,4,5,6,7,8,9,10,11,12,13]
			},
			moveRight: {
                                animSheet: "runAnimSheet",
				frameTime: 0.06, 
				sequence: [16,17,18,19,20,21,22,23,24,25,26,27]
			}
         },
        animsExpected: ["idle", "move"],
        // OVERRIDING addAnim to support multiple animation sheet in animSettings:
        addAnim: function (name, settings ) {
            if (!this.animSheet) {
                throw( 'No animSheet to add the animation ' + name + ' to.' );
            }

            if (settings.animSheet === undefined) {
                var animation = new ig.AnimationExtended(this.animSheet, settings );
            } else {
                var animation = new ig.AnimationExtended(this[settings.animSheet], settings ); 
            }
            this.anims[name] = animation;
            if (!this.currentAnim) {
                this.currentAnim = animation;
            }

            return animation;
         }

Thank you!!!! :)

1 decade ago by shalafi

So I am new to Impact, and stumble acrossed Impact++ and love the ad dons its provides. However, I am trying to learn by reverse engineering and I am ending up a bit confused.

For instance, in the examples there no update or draw. Are those moved over to eac specific entity? I see in jumpnrun the player entity has update Changes, is that in lieu of the one in main.js?

So there a bunch of these differences when designing for impact++ versus normal impact. Is there a do's and don't guide for using impact++?

1 decade ago by collinhover

@shalafi there is no do/don't guide as of yet. Entity update is actually broken down into a number of parts to allow you to opt-in with the performance (http://collinhover.github.io/impactplusplus/ig.EntityExtended.html#performance) property. All the original methods such as update() and draw() are still called, but I've tried to break down the update process into semantic parts so that only certain pieces need to be overriden. All the parts are listed here: http://collinhover.github.io/impactplusplus/ig.EntityExtended.html#update (looks like the docs has a few typos at the moment, sorry).

So to give you a specific example, the updateChanges method is where the entity modifies itself, doing things such as moving, jumping, climbing, abilities, etc. This method can be blocked by setting an entity's controllable property to false. Next in the update process comes the updateDynamics (only called if performance === ig.EntityExtended.PERFORMANCE.DYNAMIC ) which handles velocity, accel, collision map hits, etc. Then, the visible property is set based on whether the entity is within the screen, and if it is, the updateVisible method is called which handles updating animations and such. Of course, if an entity is not visible, there is no need to worry about animating or drawing.

Splitting functions into semantic parts is a common pattern in Impact++. Another example is the init process:

init
  V 
    initTypes (adding types, checkAgainst, groups)
  V
    initProperties (add one time properties, such as timers)
  V
    reset
      V
        resetCore (set initial position, merge settings)
      V
        resetExtras (change properties based on merged settings)

Hope this helps.

1 decade ago by shalafi

Yes it helps, I am also new to javascript, so I am watching a bunch of tutorials on namespace, extends, JSON and things of that nature. Any recommendation of something I should also brush up on so I can better understand the topology of impact++

1 decade ago by collinhover

@shalafi I've got nothing in particular for you other than a note that ImpactJS uses several patterns which arenot native to javascript, namely classes and modules. Impact++ is really only a layer on top of ImpactJS, so the basic concepts are all the same.

1 decade ago by shalafi

@collin Well just an update, I understand now. I watched this video http://www.youtube.com/watch?v=PMfcsYzj-9M and with your explanation it all made sense. I was able to integrate some functionality into my first game.

Proper syntax's are making my progress very slow.

For instance, I was watching the node.js impact video, and so he the author decides to make a chat function.

So first he grabs a variable from the player, he uses this method.

 var playerLocal = this.getEntitiesByType(EntityPlayer)[0];

 this.font.draw( playerLocal.playerText, 100, 100, ig.Font.ALIGN.CENTER );

So I tried to do that, it said Uncaught TypeError: Cannot read property 'playerText' of undefined. However, it vanhalla video he used the same code and worked perfect. Also it caused my character to run and fire all weapons, which i found funny.

Then I looked into the impact++ library and found this:

var playerLocal = ig.game.getPlayer('player');

this.font.draw( playerLocal.playerText, 100, 100, ig.Font.ALIGN.CENTER );

and it worked perfect.

I am confused why the first method does not work.

Also just FYI
console.log( EntityPlayer.prototype.playerText);

works also.

1 decade ago by collinhover

@shalafi About the playerText property, I've never seen that property. It certainly isn't built into Impact++. Keep in mind that because ImpactJS has been around for going on 5(?) years now, and Impact++ is only 3-4 months old, most or all of these videos using ImpactJS do not use Impact++. Additionally, Impact++ adds some things that require changes to the ImpactJS core (usually for performance or bugfix reasons), which usually you will never notice, but in some fringe cases they may show up.

A good example is the getEntitiesByType function. The type property is a bitwise flag, but in original ImpactJS getEntitiesByType searches by class, not by type. Because this is confusing, in Impact++ getEntitiesByType actually searches by a bitwise flag type, and I added getEntitiesByClass to search by class. This is most likely why the first method did not work.

As for getting a player, just use ig.game.getPlayer() as in almost all cases it is much faster than getEntitiesByType. Getting all entities by type searches through every single entity in your game, and is generally a bad idea unless you are actually trying to find a group of entities. Otherwise, like we do with the player by default, give it a name and retrieve it by that unique name (which is what getPlayer tries first).

1 decade ago by BennyT

Hi Collin,

Just thought I would let you know that when you are using the standard default line to include a font:

font: new ig.Font( 'media/04b03.font.png' ),

and then add the latest version of impact++ (just downloaded 30min ago from the homepage, not GitHub clone) there is a font conflict.

In the core.config file at line 643 the font definition is this:

ig.CONFIG.FONT.MAIN_NAME = "04b03_white_8.png";

which doesn't match up to the filename of default impactJS.

Not sure if this is the best place to raise it, but I might not be the only one to have this issue.

1 decade ago by collinhover

@BennyT: "04b03_white_8.png" is the name of the font image included in the media folder of Impact++. There are several at different sizes and in black and white, so I wanted to make it clear which is which. Don't forget to copy over the media folder =)

1 decade ago by Herry

Hi guys,

I has a problem. Please help me.

I try to use impact++ with new code.
My main.js
ig.module(
        'game.main'
    )
    .requires(
        'plusplus.core.plusplus',
        //'impact.game',
        'game.levels.default',
        'plusplus.debug.debug'
    )
    .defines(function () {
        "use strict";
        var _c = ig.CONFIG;
        var MyGame = ig.GameExtended.extend({

            init: function () {
                this.loadLevel(ig.global.LevelDefault);
            },

            update: function () {
                // Update all entities and backgroundMaps
                this.parent();

                // Add your own, additional update code here
            },

            draw: function () {
                // Draw all entities and backgroundMaps
                this.parent();
            }
        });

        ig.main('#canvas', MyGame, 60, _c.GAME_WIDTH, _c.GAME_HEIGHT, _c.SCALE, ig.LoaderExtended);

    });

and my LevelDefault is empty render by weltmeister.

When my load my page it has error

Uncaught Error: Attempting to add item/entity to layer named backgroundMaps and that layer doesn't exist. Your item needs a 'layerName' property with a value matching one of the existing game layer names:

i don't know reason!

Please help me.

1 decade ago by collinhover

@Herry your MyGame init method needs to call this.parent() so the game can set up the layers properly.

(edit: you point out a bit of a design flaw in the way layers are set up... the above should fix it but I'm going to revise the game init some to try and fix this)

1 decade ago by Herry

Quote from collinhover
@Herry your MyGame init method needs to call this.parent() so the game can set up the layers properly.


Oh no! a my mistake stupid.

Thanks for your help! Collinhover

1 decade ago by collinhover

Impact++ is now at release r6.

Download and Changlog:
https://github.com/collinhover/impactplusplus/releases/tag/r6

Documentation:
http://collinhover.github.io/impactplusplus/

1 decade ago by Justos

Hey guys! first, I want to say great job with the lib. So much stuff to help make my game even more awesome!

That said, Im having an issue with the setup. Ive done everything correctly (from the docs at least) and I cant load the game! It gets stuck on the loader with no console errors.

It was giving me issues with /media files before, so i just copied everything from the example into my own folder and it seems to have resolved that, but now the game wont actually load!

www.pauloaguiar91.com to try it out...

I can post my code if necessary. but its pretty standard, im not sure why it isnt working :S

1 decade ago by collinhover

Can you check the console for any errors and post those?

1 decade ago by lunarcloud

I'm working on a top-down game, and I've noticed the default player physics are slow and floaty. I tried playing around with user config stuff, but if it was the right speed, then the friction was messed up. It's like an ice level and I'm not sure how to fix it.

1 decade ago by pattentrick

@lunarcloud

Could you post your user config? My latest impact++ game is also a top down game, and i have no problems with the movement, so maybe i could help you with figuring out what to do.

By the way, i just edited the max vel of the player and everything was perfect from the start:

            // character movement speed
            CHARACTER: {
                MAX_VEL_GROUNDED_Y: 30,
                MAX_VEL_GROUNDED_X: 30
            }

1 decade ago by Ralliare

This seems so damn good, But god I have no bloody idea what I'm doing. The documentation leaves out such a large chunk of explanation. Took me a god few hours to get the required files out of the test games as it kept trying to call non standard fonts and files that I had no idea it required.

I really can't decide if it's worth while struggling to get this working or to build the fnctionality I need from scratch.

1 decade ago by pattentrick

@Ralliare

Just post a Issue at the github page if you are stuck with something:

https://github.com/collinhover/impactplusplus/issues?page=1&state=open

Collin, or other devs, will take a closer look at your problems. This thread is not very heavily frequented at the moment. Just out of curiosity, which part of ++ do you think deserves more explanation? The setup? Some certain features?

1 decade ago by pattentrick

@ Everyone

collinhover and myself are currently discussing on adding some basic examples/tutorials to ++ on GitHub:

https://github.com/collinhover/impactplusplus/issues/123

The whole topic is open to suggestions. So if anyone out there thinks, that a certain ++ feature needs more explanation for beginners, please post your ideas there.

1 decade ago by pattentrick

The new Impact++ r7 release is out now!

It includes a whole slew of bug fixes and scaling enhancements for retina devices. Also there are some new awesome tutorials online at the project page:

http://collinhover.github.io/impactplusplus/

Right now there are tutorials available about getting started, the player abstract, the creature abstract, the character abstract, pathfinding, dynamic lighting, the camera, UI elements and conversations.

1 decade ago by collinhover

I've been really busy with another project, but with the help of @pattentrick we've been keeping on top of any github issues and questions. Please don't hesitate to ask any questions there, and don't forget to check out the new tutorials section on the docs site. Credit goes to @pattentrick for starting and writing most of it!

10 years ago by Ralliare

@pattentrick

I read the new tutorials and they're a big help. It would be amazing if you could throw together some extremely simple examples of game mechanics made with plusplus though. the Demo's do a good job of illustrating what is possible, but with so many new features it's quite hard to see where one thing stops and another starts when they're all in one.

10 years ago by jtokarchuk

I need some help.

Been working on player movement last night (and I do enjoy how it 'just works') -- however I need to tweak my top down movement.

currently he moves way too fast. if I change velocity or friction, or maxvel, it does nothing. If I change his speed and accel, I cant seem to stop him from slowly speeding up and easing his way down. I'm looking for constant speed movement (link to the past style) -- how can I achieve this?

- Also, if you head over to http://tokarchuk.org/game , I would like the viewport to be 160x144 and scaled like that, instead of showing more of the level to expand the size. How may I achieve this?
Page 5 of 6
« first ‹ previous next › last »