Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[SUB] Starfield #231845
10/17/08 09:18
10/17/08 09:18
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
Hello i decided to contribute with this little code.
Istead of using a skycube with stars, that look bluured, you can use this entity based starfield.
- It blinks like real stars do
- Blue / Red color shift distribution
- Rendered bellow all entities.
- Follow player

->Add this image file to your project:


DOWNLOAD IMAGE

Code:
/// NUMBER OF STARS
int star_limit=200;
//// star props
void starf_f(ENTITY* p) {

set(p,TRANSLUCENT | BRIGHT | LIGHT );
// Add random color based on red
p.red=225-random(90);
p.green=150;
p.blue=200-random(90);

while(1){
//blinking effect	
p.alpha=50+random(50);
vec_set(you.pan,camera.pan);
//keep star size all the same and not by their distance to camera
you.scale_x=vec_dist(you.x,camera.x)/8200;
you.scale_y=you.scale_x;
you.scale_z=you.scale_x;
wait(1);
}
}


//// CREATOR
VECTOR star_pos;
int starf_count=0;
var angle;
while (starf_count<star_limit) {
angle=random(360);
  star_pos.x=camera.x + 100000 * cos(random(360)) * cos(random(360));
  star_pos.y=camera.y + 100000 *sin(random(360)) * cos(random(360));
 star_pos.z=camera.z + 100000 * sin(random(360));
 

  you=ent_createlayer("star_point.tga",SKY,2);
  you.x=star_pos.x;
  you.y=star_pos.y;
  you.z=star_pos.z;
  starf_f(you);
  starf_count++;
 
}
}





Last edited by MMike; 10/17/08 09:26.
Re: [SUB] Starfield [Re: MMike] #238346
11/26/08 19:56
11/26/08 19:56
Joined: Nov 2008
Posts: 24
Nevada, USA
Kevinper Offline
Newbie
Kevinper  Offline
Newbie

Joined: Nov 2008
Posts: 24
Nevada, USA
I just found this. This looks like exactly the kind of thing I'm looking for. Now to see if I can make it work (I'm an idiot with Lite-c so far).


Kevin
Re: [SUB] Starfield [Re: Kevinper] #238350
11/26/08 20:38
11/26/08 20:38
Joined: Nov 2008
Posts: 24
Nevada, USA
Kevinper Offline
Newbie
Kevinper  Offline
Newbie

Joined: Nov 2008
Posts: 24
Nevada, USA
I got a syntax error when I ran it but deleted that last bracket and it compiled but I haven't been able to make it work yet.


Kevin
Re: [SUB] Starfield [Re: Kevinper] #238873
11/30/08 21:25
11/30/08 21:25
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Code:
/*
starfield by MMike (Lite-C)
Hello. I decided to contribute with this little code.
Instead of using a skycube with stars, that look blurred, 
you can use this entity based starfield.
- It blinks like real stars do
- Blue / Red color shift distribution
- Rendered bellow all entities
- Follow player

->Add this image file to your project: star_point.tga
*/

//file: starfield.c
//images: star_point.tga

#include <acknex.h>
#include <default.c>

/// NUMBER OF STARS
int star_limit=500;
var star_dist = 30000; //-tD
//// star props

/******************************
	starf_f
*******************************/
void starf_f(ENTITY* p) {
	set(p,TRANSLUCENT | BRIGHT | LIGHT );
	// Add random color based on red
	p.red=225-random(90);
	p.green=150;
	p.blue=200-random(90);

	while(1){
		//blinking effect	
		p.alpha=50+random(50);
		vec_set(you.pan,camera.pan);
		//keep star size all the same and not by their distance to camera
		you.scale_x=vec_dist(you.x,camera.x)/8200;
		you.scale_y=you.scale_x;
		you.scale_z=you.scale_x;
		wait(1);
	}
}
/******************************
	starf_init
*******************************/
void starf_init() {
	//// CREATOR
	VECTOR star_pos;
	int starf_count=0;
	var angle;
	while (starf_count<star_limit) {
		angle=random(360);
		star_pos.x=camera.x + star_dist * cos(random(360)) * cos(random(360));
		star_pos.y=camera.y + star_dist *sin(random(360)) * cos(random(360));
 		star_pos.z=camera.z + star_dist * sin(random(360));
		you=ent_createlayer("star_point.tga",SKY,2);
		you.x=star_pos.x;
		you.y=star_pos.y;
		you.z=star_pos.z;
		starf_f(you);
		starf_count++;
	}
}
/******************************
	main
*******************************/
void main() {
	vec_set(screen_color, vector(1, 1, 1));
	vec_set(sky_color, vector(1, 1, 1));
	video_mode = 7;
	video_screen = 1;
	level_load("");
	wait(3);
	starf_init();
}


Re: [SUB] Starfield [Re: testDummy] #239027
12/01/08 22:14
12/01/08 22:14
Joined: Nov 2008
Posts: 24
Nevada, USA
Kevinper Offline
Newbie
Kevinper  Offline
Newbie

Joined: Nov 2008
Posts: 24
Nevada, USA
testDummy, you are ny hero. I appreciate the time and effort for the response so I can try and get a grasp on this.

Many Thanks!



Last edited by Kevinper; 12/01/08 22:15.

Kevin
Re: [SUB] Starfield [Re: Kevinper] #291162
09/23/09 16:13
09/23/09 16:13
Joined: Jul 2004
Posts: 1,710
MMike Offline OP
Serious User
MMike  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,710
Im updating this one.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1