Recent posts by Uneon on Kongregate

Flag Post

Topic: Game Programming / Pulling questions from a xml randomly

Sorry but that doesn’t really help me

 
Flag Post

Topic: Game Programming / Pulling questions from a xml randomly

Hey,

I am working on a game which also contains a quiz. For the quiz the questions and answers are pulled from a xml. The problem is the it always loads the first question in the xml first and i would like this to be more random.

var questions:Array=new Array();
var answers:Array=new Array();

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest("sample.xml"));

trace(score);

function loadXML(e:Event):void
{
        var myxml = new XML(e.target.data);
		var loop = score;
		for (var i= 0 ;i<(loop);i++){questions[i]=myxml.ques[i].q1;
		answers[i]=[myxml.ques[i].op1,myxml.ques[i].op2,myxml.ques[i].op3];
 
		}
		gotoAndPlay(currentFrame + 1);
		}
stop();

This is the code that loads the xml

I tried this but it didn’t work I used 5 but this could also be math.random and (loop + i)

 var myxml = new XML(e.target.data);
		var loop = score;
		for (var i= 5 ;i<(loop + 5);i++){questions[i]=myxml.ques[i].q1;
		answers[i]=[myxml.ques[i].op1,myxml.ques[i].op2,myxml.ques[i].op3];

Anyone got any idea
this is the tutorial that was used http://flashbynight.com/tutes/quiz/

Thanks

 
Flag Post

Topic: Game Programming / Need help with several problems(such as enemy clipping and loading movieclips into an array)

Ahh great, I thought y values increased if you went down. Got it now thanks for the quick response.

 
Flag Post

Topic: Game Programming / Need help with several problems(such as enemy clipping and loading movieclips into an array)

Hey,
I am very new to as3 and due to me being sick I am behind on schedule and I could really use some help. Basically I made a top down evasion game. Using this tutorial as a basis http://www.flashgametuts.com/tutorials/as3/how-to-make-a-vertical-shooter-in-as3-part-1/.

I have several problems I have to solve:
1: I need a scrolling background.(I do this using to movieclips but they wont switch to another value for y)

2: I need to prevent my enemies from clipping (I use multiple sorts of enemies).

3: I need to load enemies into an array to spawn them in a pattern.

Probably the most easy one is that I need and endless scrolling background.
It basically are two versions of a movieclip scrolling down and when reaching a certain value for y they should move back up. It starts of good, meaning the 2 versions scroll down but they won’t move back up.

This is the code I am using:

//The speed of the scroll movement.
var scrollSpeed:uint = 6;

//This adds two instances of the movie clip onto the stage.
var s1:ScrollBg = new ScrollBg();
var s2:ScrollBg = new ScrollBg();
addChild(s1);
addChild(s2);

//This positions the second movieclip next to the first one.
s1.y = 0;
s2.y = s1.height;

//Adds an event listener to the stage.
stage.addEventListener(Event.ENTER_FRAME, moveScroll);

//This function moves both the images to left. If the first and second 
//images goes pass the left stage boundary then it gets moved to 
//the other side of the stage. 
function moveScroll(e:Event):void
{
	s1.y +=  scrollSpeed;
	s2.y +=  scrollSpeed;

	if (s1.y <  -  s1.height)
	{
		s1.y = s2.height;
	}
	else if (s2.y < -s1.height)
	{
		s2.y = s2.height;
	}
}

Any ideas?

For the enemies I use this code here
http://www.flashgametuts.com/tutorials/as3/how-to-make-a-vertical-shooter-in-as3-part-3/

and here http://www.flashgametuts.com/tutorials/as3/how-to-make-a-vertical-shooter-in-as3-part-4/

I dont want the enemies to overlap each other so i thought i would make them hit test each other and removing one of them when the hit test is true but nothing happens.

Also I need to spawn a pattern of enemies Could you possibly help me on that?

Sorry for the wall of text, but I really need help and any help would be appreciated.

Thanks in advance.
Greetings Ryco.