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 davidx

Hi,

I just purchased a licence and I'm having a play around (great engine BTW).

I am looking to create a game with similar functionality to that of the old helicopter game, the one where you click to fly up, and release to descend and have y avoid the floor, roof and obstacles.

I have a few questions which I hope you could guide me with.

Should I use box 2d or standard entity? Box 2d seems ott to me as all I need is the chopper to assent and descend. I had a quick hack of the jumpnrun demo and set a constant x accel in the sprite update (which is wrong as I should be setting the velocity, but that's ok) but I couldn't seem to set the y accel on "jump" to keep the sprite ascending all the time the jump action was invoked. I managed this with box 2d using the physics demo, but it seems overkill to me. Any advice?

Next, I want the sprite to die when it hits the roof, floor or an obstacle. Am I better creating all these on the collision layer and listening for the collision somehow (any advise)? Or am I better using stretchable entities (similar to the triggers) in the main example?

Lastly, I attempted to place a distanced background in the physics demo (copying how it looked in the jumpnrun), but it appears to only draw itself partially and redraw as the camera moved around, do I need to set a window size or something somewhere else?

I appreciate any help, guidance, critisim or correction. I'm only learning, so you'll probably see a lot more of me in the coming days.

Thanks,

D

1 decade ago by MobileMark

You definitely just want to just use ImpactJS, as you thought, Box2D would be overkill.
You can bind the mouse click in the main,js and check in the helicopters update function if it is being pressed. If it is, helicopter's velocity in the y direction is positive, else,it is negative.

Next, to have the entity die when it hits any wall, place the code below under the update function. Using triggers would be a very inefficient way of doing this since the engine already detects these collisions :)
handleMovementTrace: function( res ) {
		this.parent( res );
		
		// collision with a wall or ceiling? death...
		if( res.collision.x ||res.collision.y ) {
			this.kill();
		}
	},	

I'm not really sure what your last question is pertaining to. It sounds like you are trying to repeat the background as you move? If you could elaborate I could try to help out a little more.

1 decade ago by dominic

The Jump'n'Run demo uses ig.input.pressed() to check for jumping, because you can only jump once per button press. The Box2D demo uses ig.input.state(), because you have a jetpack - it's not important that you just pressed the button, but that the button is still held down.

So for the helicopter game, you probably want to check for .state() not for .pressed(). And yes, using Box2D would be a bit overkill, I think :)


I'm not sure about your last question either. Maybe you just forgot to set the "Repeat" checkbox for your second background layer?

1 decade ago by davidx

Thanks a lot for the prompt replies.

I am not in front of my machine today or tomorrow, so I will update over the weekend and let you know on Monday.

Thanks again

D

1 decade ago by davidx

Thanks a bunch

I am using the kill as suggested by Mark - with some other bits from other threads, but I seem to have an issue that the animation is not being displayed (the entity is dying/disappearing) when it hits a vertical surface. All is well with hitting a horizontal.

Here is what I have on EntityPlayer:

update: function() {
	// Check if this entity is currently playing the 'die' animation
	if( this.currentAnim == this.anims.die ) {
		// Has the animation completely run through? -> kill it
		if( this.currentAnim.loopCount ) {
			this.kill();
		}
		this.currentAnim.update();
		return;
	}
...
},
	
handleMovementTrace: function( res ) {
	this.parent( res );
	// collision with a wall or ceiling? death...
	if( res.collision.x || res.collision.y ) {
		this.currentAnim = this.anims.die;
		//this.kill();
	}
}

Am I doing something stupid?

How do you guys implement level complete? Is it a trigger at a certain point which sets the game state?

Thanks,

D

1 decade ago by dominic

It looks alright. How did you define the 'die' animation? Maybe it's just to short to see?!


Quote from davidx
How do you guys implement level complete? Is it a trigger at a certain point which sets the game state?
You can do it like this, yes. Have a look at the Biolab Disaster Entity Pack - there's a trigger and another entity that loads the next level when triggered.

But it really depends on your game. E.g. when you want the level complete when all enemies are killed or you reached a certain score, you'd have to check for that in the update method.

1 decade ago by davidx

Thanks again Dominic.

My animation is defined as follows:
<code>
this.addAnim( 'die', 0.5, [0,1,2,3,4,5] );
</code>

(basically the walk animation!)

I'll look into the trigger, next level combo in the entity pack.

I am looking to create an image background as well - I tries your suggestion before about drawing the image in update and then iterating trhough my entities and calling there respective .draw()'s - but then the main layer doesn't get drawn (or else it is behind the image)?

I am going to try and create a background simular to the fences and straw here: https://mozillademos.org/demos/runfield/demo.html - am I best to use entities and then overwrite their update and use lineTo() beizers etc - or is ther e a simpler way?

Thanks for your help.

BTW - how do I add quotes, code snippets etc to posts like above for read-ability?

1 decade ago by MobileMark

If you're going the trigger route, check out MikeL's Plugin, it's pretty nice when your game has a lot of levels.
http://impactjs.com/forums/code/director-plugin

As far as formatting your post, click the "Show Formatting Help" link right above the post box and it shows all the different syntax for posts :)

It took me a while to find also
Page 1 of 1
« first « previous next › last »