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 Melimelo

Hello,

I'm new to Impact and I just read the book from jesse freeman and watched some tutorial and I had some questions.

My first questions is about background :

How would you do a background scrolling slowly over time and repeating itself infinitly. Let me show you some example to make it clear.

http://f.cl.ly/items/1p3H3T3f0T1M1Y2y1G2y/background_001.png

The background would scroll to the left and after sometime it would look like that :

http://f.cl.ly/items/1p3z0h122h3T153z2e1H/background_002.png

The red line is just to show the real limit of the pictures that is just looping there ...



My second questions is about drop :

I understand how the map is randomly generated but I was wondering if I have precalculated some map chunk and want them to follow each after an other in a random order wouldn't there be a way to optimize the number of draw calls or something ?

Thanks in advance.

Regards,

1 decade ago by paulh

set it to repeat in weitmeister for the scrolling background

1 decade ago by Melimelo

But can I put a full image as a background with the background class ?? I think I have to do it like in drop by extending ig.image but I don't know how to move it with time / tick

1 decade ago by Melimelo

Hello,

I finally succeeded to answer the first question myself trying a lot and came up with this code but I don't know if this is the right way to do it

ig.module( 
	'game.main'
)
.requires(
	'impact.game',
	'impact.image',
	'impact.debug.debug'
)
.defines(function()
{
	MyGame = ig.Game.extend(
	{
		background_1: new ig.Image('media/screen-bg.png'),
		background_2: new ig.Image('media/screen-bg.png'),
		x: 0,
		
		init: function() 
		{

		},
		
		update: function() 
		{

			this.parent();

			if(this.x + ig.system.width == 0)
			{
				this.x = 0;
			}
			
			this.x--;
		},
		
		draw: function() 
		{
			this.parent();
			this.background_1.draw(this.x,0);
			this.background_2.draw(this.x+ig.system.width,0);	
		}
	});


	// Start the Game with 60fps, a resolution of 320x240, scaled
	// up by a factor of 2
	ig.main( '#canvas', MyGame, 60, 480, 320, 1);
});



For the second question I'm still looking for answers :)

Thanks,

Regards
Page 1 of 1
« first « previous next › last »