I found this example, and it created a very nice star field. Unfortunately, it used objects which isn't terribly efficient. So, I modified the example in order for it to use an array to draw sprites. The resulting speed increase was roughly 40-60 fps. I then modified it further to separate idle and moving stars. The resulting speed increase from that was roughly 10 fps.
However, for use in the game, at a room speed of 1000; using the required number of stars, I get a fps of about 400. So, I'm hoping someone could help me optimise the current system, or provide a faster alternative.
The current system is...
Create Event:
/*
** Star Array...
**
** star[x,y]
** y...
** 0 - x
** 1 - y
** 2 - amounttomove
** 3 - alpha
*/
numbOfIdleStars=0;
numbOfStars=0;
repeat(50) {
//create star...
idleStars[numbOfIdleStars,0]=random(view_wview[0]);
idleStars[numbOfIdleStars,1]=random(view_hview[0]);
idleStars[numbOfIdleStars,2]=random(0.8)+0.2;
numbOfIdleStars+=1;
}
repeat(300) {
//create star...
stars[numbOfStars,0]=random(room_width);
stars[numbOfStars,1]=random(room_height);
stars[numbOfStars,2]=random(3000);
stars[numbOfStars,3]=random(0.6)+0.4;
numbOfStars+=1;
}Draw Event:
//draw stars...
var i,xx,yy,sx,sy;
i=0;
xx=view_xview[0]/room_width;
yy=view_yview[0]/room_height;
repeat (numbOfIdleStars) {
draw_sprite_ext(sprStar,0,view_xview[0]+idleStars[i,0],view_yview[0]+idleStars[i,1],1,1,0,c_white,idleStars[i,2]);
i+=1;
}
i=0;
repeat (numbOfStars) {
draw_sprite_ext(sprStar,0,view_xview[0]+stars[i,0]-(stars[i,2]*xx),view_yview[0]+stars[i,1]-(stars[i,2]*yy),1,1,0,c_white,stars[i,3]);
i+=1;
}Thanks to any who can help.
Edited by MasterOfKings, 12 April 2012 - 02:36 PM.












