2.5D Spaceshooter - OpenSource

Posted By: maslone1

2.5D Spaceshooter - OpenSource - 11/26/08 12:37

Hey there!

I've started a little opne-source project for the 3dgs-users.
I started this little project for the newbies.
It should help to learn scripting little projects.

here is the first version of the code.
Code:
 


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

TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE;
}


function plActor();


function main(){
	fps_max=60;
	wait(1);
	
	//Load the Environment
	level_load("");
	wait(3);
	
		ent_create("s1.mdl", vector(0,0,0),plActor);

}





function plActor()
{

var vecPos[3]   = {0,0,0};
var vecSpeed[3] = {0,0,0};
var vecAng[3]   = {0,0,0};

var mySpeed = 0;
var facCamAbst;

while(1){
mySpeed += key_force.y*time_step;
vecSpeed[1] = mySpeed*cos(my.pan);
vecSpeed[2] = mySpeed*sin(my.pan);
vecSpeed[3] = 0;

vecAng[1] -= key_force.x*10*time_step;

vec_add(vecPos[1], vecSpeed[1]);
accelerate(mySpeed, 0, 0.2);


my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 250 + facCamAbst;
camera.tilt= -90;
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed;
facCamAbst = abs(facCamAbst);


wait(1);
 }
}



with the arrow-keys you can handle the ship.
There is no level yet, so you can't see the ship-movement.
But you can load a level you made.

Some new code will follow...

cheers
Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 11/26/08 13:09

Hey, great idea !

Well done

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 11/26/08 15:55

thanx!

now a little introduction - how to use the code:


1- Create a new Project-folder on your PC.

2- Create a new ".c" -file (name for instance "game.c")
and copy the script into the file.

3- Create your space-ship mdl with med and save the model in the project-folder
The name of the space-ship model must be "s1.mdl" or you change the name in the script-file

4- That's it!

You can run your project. (one way to run the script -> drag and drop the game.c file to the acknex.exe
It will start automaticly.


The next i'll create is a code for a space-background.

CU
Marcel
Posted By: Kevinper

Re: 2.5D Spaceshooter - OpenSource - 11/26/08 20:34

Yes! Thank you.

Can you tell me how I would add MMike's Starfield to it? I can't figure it out but it might work with this.

http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=231845#Post231845
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 11/27/08 14:36

Hi Kevin!

I'll include my own version for the star-field.
Maybe,... today, or tomorrow,... i will update the script with the new features.

cu
marcel
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 12/01/08 11:28

hey friends!

a new version of the code (without stars-background):

Code:
 

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



TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE;
}


function plActor();


function main(){
	fps_max=60;
	wait(1);
	
	//Load the Environment
	level_load("");
	

	wait(3);


		ent_create("s1.mdl", vector(0,0,0),plActor);

}





function plActor()
{



var vecPos[3]   = {0,0,0};
var vecSpeed[3] = {0,0,0};
var vecAng[3]   = {0,0,0};

var mySpeed = 0;
var facCamAbst;

while(1){
mySpeed += key_force.y*time_step;
vecSpeed[1] = mySpeed*cos(my.pan);
vecSpeed[2] = mySpeed*sin(my.pan);
vecSpeed[3] = 0;

vecAng[1] -= key_force.x*10*time_step;

vec_add(vecPos[1], vecSpeed[1]);
accelerate(mySpeed, 0, 0.05);


my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 250 + facCamAbst;
camera.tilt= -90;
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*12;
facCamAbst = abs(facCamAbst);



wait(1);
 }
}



////////////////////////////////////






the next days i will create the code for the background....
hold on!

cu
Marcel Klee

Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 12/12/08 06:57

hey there!

a new version. it inludes a star-field now...
its the first version of the star-field.

you only have to create a pcx map with the a pixel-size of 24x24. the color should be white. the name of the pcx file: "star.pcx"

the code:

Code:
 



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

BMAP* star_map = "star.pcx";

var star_gen_pos[3];


TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE;
}


function plActor();
function part_alphafade(PARTICLE *p);
function effect_explo(PARTICLE *p);





function main(){
	fps_max=60;
vec_set(screen_color,vector(1,1,1)); 

	wait(1);
	
	//Load the Environment
	level_load("");
	

	wait(3);
		
				
	ent_create("s1.mdl", vector(0,0,0),plActor);
		

}





function plActor()
{



var vecPos[3]   = {0,0,0};
var vecSpeed[3] = {0,0,0};
var vecAng[3]   = {0,0,0};

var mySpeed = 0;
var facCamAbst;

while(1){
mySpeed += key_force.y*time_step;
vecSpeed[1] = mySpeed*cos(my.pan);
vecSpeed[2] = mySpeed*sin(my.pan);
vecSpeed[3] = 0;

vecAng[1] -= key_force.x*10*time_step;

vec_add(vecPos[1], vecSpeed[1]);
accelerate(mySpeed, 0, 0.05);


my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 250 + facCamAbst;
camera.tilt= -90;
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*12;
facCamAbst = abs(facCamAbst);
		
		vec_set(star_gen_pos[1],my.x);

effect(effect_explo,10 * time_step,star_gen_pos[1],normal);


wait(1);
 }
}



////////////////////////////////////



function part_alphafade(PARTICLE *p)
{

     
if(num_particles > 300) {   p.lifespan -= 1*time_step; p.alpha -= 1*time_step; }   


}

function effect_explo(PARTICLE *p)
{
   var temp[3];
   p.lifespan = random(500) - 200;

   p.x = star_gen_pos[1] + random(400) - random(400);
   p.y = star_gen_pos[2] + random(400) - random(400);
   p.z = star_gen_pos[3] + random(400) - random(400);
   p.size = random(8)-4;
   
   p.alpha = 50 + random(25);
   p.bmap = star_map;
   p.flags |= (BRIGHT | TRANSLUCENT);
   p.event = part_alphafade; 
}






next i will optimize the code and create a background. the ship-physic will get more "realistic".

cu
marcel
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 12/12/08 07:07

ok,... i quickly did some changes on the ship-physics.

the new version of the code (again wink ):

Code:


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

BMAP* star_map = "star.pcx";

var star_gen_pos[3];


TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE;
}


function plActor();
function part_alphafade(PARTICLE *p);
function effect_explo(PARTICLE *p);





function main(){
	fps_max=60;
vec_set(screen_color,vector(1,1,1)); 

	wait(1);
	
	//Load the Environment
	level_load("");
	

	wait(3);
		
				
	ent_create("s1.mdl", vector(0,0,0),plActor);
		

}





function plActor()
{



var vecPos[3]   = {0,0,0};
var vecSpeed[3] = {0,0,0};
var vecAng[3]   = {0,0,0};

var vecForce1[3] = {0,0,0};

var mySpeed = 0;
var facCamAbst;

var shipmass = 80; //80tons

while(1){
mySpeed += key_force.y*time_step/shipmass;
vecSpeed[1] += mySpeed*cos(my.pan);
vecSpeed[2] += mySpeed*sin(my.pan);
vecSpeed[3] = 0;

vecAng[1] -= key_force.x*10*time_step;

vec_add(vecPos[1], vecSpeed[1]);
accelerate(mySpeed, 0, 0.05);

accelerate(vecSpeed[1], 0, 0.05);
accelerate(vecSpeed[2], 0, 0.05);
accelerate(vecSpeed[3], 0, 0.05);


my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 550 + facCamAbst;
camera.tilt= -90;
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*12*shipmass;
facCamAbst = abs(facCamAbst);
		
		vec_set(star_gen_pos[1],my.x);

effect(effect_explo,10 * time_step,star_gen_pos[1],normal);


wait(1);
 }
}



////////////////////////////////////



function part_alphafade(PARTICLE *p)
{

     
if(num_particles > 300) {   p.lifespan -= 1*time_step; p.alpha -= 1*time_step; }   


}

function effect_explo(PARTICLE *p)
{
   var temp[3];
   p.lifespan = random(500) - 200;

   p.x = star_gen_pos[1] + random(400) - random(400);
   p.y = star_gen_pos[2] + random(400) - random(400);
   p.z = star_gen_pos[3] + random(400) - random(400);
   p.size = random(8)-4;
   
   p.alpha = 50 + random(25);
   p.bmap = star_map;
   p.flags |= (BRIGHT | TRANSLUCENT);
   p.event = part_alphafade; 
}



 



greetings
marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 12/12/08 18:40

Looking really good. I pasted the code into SED with my own model and star.tga and it worked excellently.

May I make a slight suggestion please, add a few comments in for people who are learning ??

Thank you for your great contribution

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 12/12/08 19:46

hey dracula!

shure.... i will do some comments
i also will create a workshop....
with help of some other persons.... wink

Code:
 

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

BMAP* star_map = "star.pcx"; //define a bitmap called star_map

var star_gen_pos[3]; //variable -> will safe coordinates


TEXT* help = { //create a text on screen
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE; //make text visible
}


function plActor(); //function-prototype for the player
function part_alphafade(PARTICLE *p); //particle function
function effect_explo(PARTICLE *p); //particle function


function main(){ 
	fps_max=60;

	
	//Load the Environment
	level_load("");
	
	wait(3);
					
	ent_create("s1.mdl", vector(0,0,0),plActor);
	//create the player in the level	
        //vector(0,0,0) is the start-position of the ship
}





function plActor()
{


//for the movement we need 3 var-arrays
//1- for the Ship Position -> vecPos[3]
//2- for the Ship-Speed -> vecSpeed[3]
//3- for the Ship-Direction -> vecAng[3]

//You will alse see vecForce1[3]
//This is one of the other forces you can use.
//for instance for gravitation or some other kinds of energie
//mySpeed is the force used for a "constant" force in x-
//direction of the ship.


var vecPos[3]   = {0,0,0}; //i initialize all with zero
var vecSpeed[3] = {0,0,0}; //so there is no bad faulty effect
var vecAng[3]   = {0,0,0}; //at the game-start

var vecForce1[3] = {0,0,0}; //use this var array for slide-effects :)

var mySpeed = 0;
var facCamAbst; //this is only used as a factor for
                //the cam-movement

var shipmass = 80; //80tons -> change this to change the ship
                   //setup

while(1){
//with the arrow-key-Y you change the force.
mySpeed += key_force.y*time_step/shipmass;

//with pan and the trigometrics you calculate the vector
//vecSpeed in x and y diriction

vecSpeed[1] += mySpeed*cos(my.pan);
vecSpeed[2] += mySpeed*sin(my.pan);
vecSpeed[3] = 0;

//-----------------------------------------/*
//this a possible way to add a slide-function:

vecForce1[1] += mySpeed*key_force.x/shipmass*cos(my.pan-90);
vecForce1[2] += mySpeed*key_force.x/shipmass*sin(my.pan-90);
vecForce1[3] = 0;

vec_add(vecPos[1], vecForce1[1]);
accelerate(vecForce1[1], 0, 0.05);
accelerate(vecForce1[2], 0, 0.05);
accelerate(vecForce1[3], 0, 0.05);

//i havent tested this, but it should work.
//play with the values....
-------------------------------------------*/


vecAng[1] -= key_force.x*10*time_step;

vec_add(vecPos[1], vecSpeed[1]);
accelerate(mySpeed, 0, 0.05);

//i use accelerate to "simulate" friction
//change the value 0.05 to .... 0.9 -> you will see the changes

accelerate(vecSpeed[1], 0, 0.05);
accelerate(vecSpeed[2], 0, 0.05);
accelerate(vecSpeed[3], 0, 0.05);


my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

//here comes some functions for the cam
camera.x = my.x; //there exists some easier ways to set the
camera.y = my.y; //position -> vec_set(camera.x, my.x)
camera.z = my.z + 550 + facCamAbst; 
camera.tilt= -90; //cam-diretion - down
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*12*shipmass; //integrate the shipmass
 //to prefent a to big distance

facCamAbst = abs(facCamAbst);
		
		vec_set(star_gen_pos[1],my.x);

effect(effect_explo,10 * time_step,star_gen_pos[1],normal);
//create particles for the star-field

wait(1);
 }
}

//more comments will follow
//first i will optimze the code....

////////////////////////////////////



function part_alphafade(PARTICLE *p)
{

     
if(num_particles > 300) {   p.lifespan -= 1*time_step; p.alpha -= 1*time_step; }   


}

function effect_explo(PARTICLE *p)
{
   var temp[3];
   p.lifespan = random(500) - 200;

   p.x = star_gen_pos[1] + random(400) - random(400);
   p.y = star_gen_pos[2] + random(400) - random(400);
   p.z = star_gen_pos[3] + random(400) - random(400);
   p.size = random(8)-4;
   
   p.alpha = 50 + random(25);
   p.bmap = star_map;
   p.flags |= (BRIGHT | TRANSLUCENT);
   p.event = part_alphafade; 
}




cheers

Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 12/12/08 20:04

u wont believe me, but "you could use this code" for a game like gta 1 or gta 2. with some new variables and functions it would be possble.

but we create a "space-game". wink


a new version again:

(comments will follow, but you can ask me if you have questions)

Code:

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

BMAP* star_map = "star.pcx";
BMAP* star_map2= "starmap.dds";

var star_gen_pos[3];

var star_map_pos[25][3];

ENTITY* plSHIP;


TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=55; blue=55;
	flags=VISIBLE;
}


function plActor();
function part_alphafade(PARTICLE *p);
function effect_explo(PARTICLE *p);





function main(){
	
	video_mode = 6; // create a program window of 640x480 pixels

	
	
	//Load the Environment
	level_load("");
	

	wait(3);
		
	fps_max=60;			
	ent_create("s1.mdl", vector(0,0,0),plActor);
	
	
	
}





function plActor()
{

plSHIP = me;

var vecPos[3]   = {0,0,0};
var vecSpeed[3] = {0,0,0};
var vecAng[3]   = {0,0,0};

var vecForce1[3] = {0,0,0};

var mySpeed = 0;
var facCamAbst;

var shipmass = 80; //80tons

while(1){
mySpeed += key_force.y*time_step/shipmass;
vecSpeed[1] += mySpeed*cos(my.pan);
vecSpeed[2] += mySpeed*sin(my.pan);
vecSpeed[3] = 0;


vecAng[1] -= key_force.x*15*time_step;

vec_add(vecPos[1], vecSpeed[1]);

accelerate(mySpeed, 0, 0.05);

accelerate(vecSpeed[1], 0, 0.05);
accelerate(vecSpeed[2], 0, 0.05);
accelerate(vecSpeed[3], 0, 0.05);


vecForce1[1] -= mySpeed*key_force.x/shipmass*cos(my.pan-90);
vecForce1[2] -= mySpeed*key_force.x/shipmass*sin(my.pan-90);
vecForce1[3] = 0;

vec_add(vecPos[1], vecForce1[1]);
accelerate(vecForce1[1], 0, 0.05);
accelerate(vecForce1[2], 0, 0.05);
accelerate(vecForce1[3], 0, 0.05);



my.pan  = vecAng[1];
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;
camera.y = my.y;
camera.z = my.z + 550 + facCamAbst;
camera.tilt= -90;
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*15*shipmass;
facCamAbst = abs(facCamAbst);
		
		vec_set(star_gen_pos[1],my.x);

if(num_particles < 300) { effect(effect_explo,50 * time_step,star_gen_pos[1],normal); }


wait(1);
 }
}



////////////////////////////////////



function part_alphafade(PARTICLE *p)
{

  var distanz;
  var rand_alpha;
	p.alpha = 1;
	rand_alpha = random(100)-50;
	if(p.alpha < rand_alpha) { p.alpha+=1;}
  
   p.lifespan = 1;
   distanz = vec_dist(p.x, plSHIP.x);
     
if(num_particles > 1000) {   p.lifespan = 0; }   
if(distanz > 600) { p.lifespan = 0; }

}

function effect_explo(PARTICLE *p)
{
   var temp[3];
   p.lifespan = random(500) - 200;

   p.x = star_gen_pos[1] + random(600) - random(600);
   p.y = star_gen_pos[2] + random(600) - random(600);
   p.z = star_gen_pos[3] + random(600) - random(600);
   p.size = random(8)-4;
   
   p.alpha = 50 + random(25);
   p.bmap = star_map;
   p.flags |= (BRIGHT | TRANSLUCENT);
   p.event = part_alphafade; 
}




 



the star-field looks better now (i think so, but you can tell me if u dont like it)

greetings
marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/05/09 19:12

Next instalment please !!

Drac.
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/11/09 16:41

speak to me !

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/12/09 17:43

Hey Drac!

smile smile


sorry for my late answere...(i have lot of other work to do)
i will integrate new things if i find time again.

But feel free to try scripting some new functions.

cu
Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/12/09 18:05

Thanks, I look forward to it !

Drac.
Posted By: ryangregory

Re: 2.5D Spaceshooter - OpenSource - 01/13/09 17:08

Great little demo, I really like it. I could see this making a good game if you develop it further.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/15/09 17:35

hey ryangregory!

thanx, but what demo u mean??

I had a look at your website,
i realy like your conzept-art! Realy nice work!

cheers!
Marcel
Posted By: Xarthor

Re: 2.5D Spaceshooter - OpenSource - 01/15/09 21:08

hi maslone1,
great project!
I got one question though, what is this:
starmap.dds

I know that its an image file, could you maybe upload yours or describe how it should look?

thanks, I'm looking forward to contribute to this nice project.

greetings
xarthor
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/18/09 17:35

Hi Xarthor!

The starmap.dds have no function in this version of the code.
Maybe i'll use it for a new version of the star-filed... maybe.

I am sorry, i havent continued the work for this project.
I have to complete an another project first.

CU Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/18/09 17:42

Hi maslone,

Shooting & collisions would be good !

If you got a simple (expandable) game completed, I don't see why Conitec shouldn't ask you to add it to their work folder. The only complete game example there at the moment is Pong. This is crazy. People want starter examples in one place, they shouldn't have to hunt all over the forums, wiki, AUM etc, etc

Drac.
Posted By: Xarthor

Re: 2.5D Spaceshooter - OpenSource - 01/18/09 19:11

Hi maslone1,
thanks, I could have guessed that by looking through the code, but meh wink

why should you always be the one that updates the code? I thought this is intended to be an open-source community project? Or is it not?

cya
xarthor
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/18/09 20:26

2 reasons:

1. It's his baby
2. He is a living god and we are not worthy to change his creation.

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/19/09 11:39

smile sorry, but i am not a god.
I am just a little programer, grafic-artist, music-artist....

My plan:

- Complete the other project (will be soon)

About the 2.5 Spaceshooter:
- Write a documentation for the script for better understanding
- add functions to the ship

cheers

Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/19/09 12:15


here u will find a little code description.
hope it will help u.
remember, a better documentation with a workshop will follow soon.

Code:

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




BMAP* star_map = "star.pcx";
var star_gen_pos[3];		//Starfield-Generator position



//Create a text on the left-top corner
//START//

TEXT* help = {
	string = "TEST-PROGRAMM - CREATED BY MARCEL KLEE";
	red = 255; green=255; blue=255;
	flags=VISIBLE;
}

//END//



//////////////////////////////////////////////////////////
//Create Functions-Prototype//////////////////////////////
//////////////////////////////////////////////////////////
//START//

function plActor();
function part_alphafade(PARTICLE *p);
function effect_explo(PARTICLE *p);

//END//



function main(){
	fps_max=60;
vec_set(screen_color,vector(1,1,1)); 

	wait(1);
	
	//Load the Environment
	level_load("");
	

	wait(3);
		
				
	ent_create("s1.mdl", vector(0,0,0),plActor);
		

}


//////////////////////////////////////////////
///////////   PLAYER FUNCTION   //////////////
//////////////////////////////////////////////
//The player-ship function
//START//

function plActor()
{

var vecPos[3]   = {0,0,0};     //Position-Vector
var vecSpeed[3] = {0,0,0};     //Speed-Vector
var vecAng[3]   = {0,0,0};     //Angular-Vector

//var vecForce1[3] = {0,0,0};  //Other force-Vectors ... function coming soon

var mySpeed = 0;  //mySpeed describes the Engine-Force
var facCamAbst;   //For the camera-distance to the playership -> only a factor x

var shipmass = 80; //80tons --- for the force calculation

while(1){

mySpeed += key_force.y*time_step/shipmass; 
//calculate the effective force of the ship
//mySpeed adds the key_force (pressed = 1, not pressed = 0) * time_step / shipmass (80).
//The shipmass is only a factor. You can also say "hey the weight isn't 80tons, its 80 bannanas ;)
//For instance:    Frame 1 ->  mySpeed += 0*time_step/80 = 0.      key not pressed = false
//For instance:    Frame 2 ->  mySpeed += 1*time_step/80 = 2,10.   key pressed = true
//For instance:    Frame 3 ->  mySpeed += 1*time_step/80 = 2,10 + 2,10 = 4,20.  ....and so on.....
//So how i use this "effective Force"?
//The effective Force only descripes the force we need to calculate a part of the speed vector.
//why only a part? -> there are maybe other forces. Maybe a collision with a other ship, or a explosion....
//We will see later.....



vecSpeed[1] += mySpeed*cos(my.pan);
vecSpeed[2] += mySpeed*sin(my.pan);
vecSpeed[3] = 0;
//Here we use the cos and sin function with mySpeed (we rember -> the effective force)
//to calculate the direction of the force + the force itself (vector-length)
//Attention! -> this will only calculate the vector for the engine-force.
//if we wanna use other forces, we have to write it again (or we write a function/macro)


vecAng[1] -= key_force.x*10*time_step;
//calculate the pan-angle for the player ship.

vec_add(vecPos[1], vecSpeed[1]);
//add the speed-vector to the position-vector of the ship.


accelerate(mySpeed, 0, 0.05);
accelerate(vecSpeed[1], 0, 0.05);
accelerate(vecSpeed[2], 0, 0.05);
accelerate(vecSpeed[3], 0, 0.05);
//its my way to simulate the friction.
//an other way: vecSpeed[1] *= vecSpeed*(0,95^time_step); 
//i think it should also work.... i dont know yet.


my.pan  = vecAng[1];  //nanonanet -> set my.pan to vecAng[1].
my.tilt = 0;
my.roll = 0;

my.x = vecPos[1];     //set my position to the vecPos.
my.y = vecPos[2];
my.z = vecPos[3];

camera.x = my.x;      			 //set camera Position to my position
camera.y = my.y;
camera.z = my.z + 550 + facCamAbst;  //my.z+550quants = the base-distance to my ship + factor facCamAbst
						 //facCamAbst is dynamic. (for instance speed * factor)
camera.tilt= -90; 			 //camera look straight down to the ship.
camera.roll= 0;
camera.pan = 0;

facCamAbst = mySpeed*15*shipmass;   //this is the "dynamic" camera factor.
facCamAbst = abs(facCamAbst);       
		
		vec_set(star_gen_pos[1],my.x);  
		//here we copy the my position information into the star_gen_pos vector.


effect(effect_explo,10 * time_step,star_gen_pos[1],normal);
//i use the particle effect generator for the starfield (i know, not the right name for this effect)

wait(1);
 }
}



////////////////////////////////////



function part_alphafade(PARTICLE *p)
{

     
if(num_particles > 300) {   p.lifespan -= 1*time_step; p.alpha -= 1*time_step; }   


}

function effect_explo(PARTICLE *p)
{
   var temp[3];
   p.lifespan = random(500) - 200;

   p.x = star_gen_pos[1] + random(600) - random(600);
   p.y = star_gen_pos[2] + random(600) - random(600);
   p.z = star_gen_pos[3] + random(600) - random(600);
   p.size = random(8)-4;
   
   p.alpha = 50 + random(25);
   p.bmap = star_map;
   p.flags |= (BRIGHT | TRANSLUCENT);
   p.event = part_alphafade; 
}

 



cheers
Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 01/19/09 14:00

Thanks

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/03/09 06:19

Hey there!

I have some news:

I have changed the code. It is now "open-source-friendly".
Now i'll write a workshop, to show you how to use the code,
or to create new functions for the game.
Maybe coming weekend, its ready for download.


ciao
Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 02/04/09 20:46

Great !

Thanks

Drac.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/08/09 19:10

deleted
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/08/09 19:12

i am back....


here is the latest version (sorry, but - without a workshop).
But the workshop will follow. Also a little manual.


Filefront download 2_5 Spaceshooter

Now it is version V.0.1

Have fun with it!

Cheers
Marcel
Posted By: Quad

Re: 2.5D Spaceshooter - OpenSource - 02/08/09 19:19

link redirects to filefront main page.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/08/09 19:21

realy... hmmm, please test it again.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/12/09 06:53

Hello!

Some news:

I have a new version of the code + new functions.
Now the code includes 2 kinds of gravity (maybe for planets or black-holes,.......)
For now, i have included 2 Planets-> one with gravity-force and one with anti-gravity-force.
The gravity-function could also be used for explosion or implosion - effects. Now i am working on the workshop and the manual....

cu
Marcel
Posted By: dracula

Re: 2.5D Spaceshooter - OpenSource - 02/13/09 10:28

When's the shooting and killing going to start ?
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/14/09 09:10

Hey folks!


the new version:

File Front download 2_5D Spaceshooter V0_12


The workshop is still not finished....sorry...
but i hope this contribution help you to create own projects!

About the gameplay:
with the arow-keys you move the ship.
with "1" and "2" you select the weapon-type.
with space you fire the weapon you've selected.

with backspace you select "no weapon".

the weapon type 2 is not finished.
you can select it, but can't use it.
but u can add the weapon you want....


Cheers
Marcel


Posted By: ortucis

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 00:11

Odd. Selecting any weapon (even after publishing it) crashes the game for me (vista x64 Ultimate). Other than that, I can fly around just fine.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 17:52

what version of a7 you have? i use a7.7.
i have no errors after publishing the project.

-> sorry, but i can't help u. maybe u have changed something in the code and there is now a little bug...??

write me if you have found the problem....

cu
Marcel
Posted By: ortucis

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 19:19

I am using 7.66 trial, so maybe I should give 7.7 a try to see if it workd (I didn't bother updating this time).
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 19:32

hmmm... trial-version.
Maybe thats the reason.... i don't know....
Posted By: ortucis

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 19:48

Yup, works fine with 7.7o trial. smile

Just to be sure, the ship moving into the golf balls when in their radius is intentional, right? (EDIT: My bad, it says in the code, Gravity Planet)

Also, I find it odd that instead of floating into the direction it was going when stopped, the ship starts moving upwards (well, top of the screen). Anyways, this looks really cool, so please keep updating it. laugh

*starts again.. pew pew pewww..*



Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/23/09 20:28

it works,.... good to hear.

and yes,... the 2 planets have different cind of gravity.

1 planet have a positiv gravity,
and the other gravity have negativ gravity.

updates will follow.....

cheers
marcel
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 02/26/09 18:50

Oh yes... a new version coming soon.

It includes a little (animated) menue,
you can include many many planets with individual gravity-forces, and some more little things,....
Posted By: Felixsg

Re: 2.5D Spaceshooter - OpenSource - 05/14/09 14:26

you have abandoned this?
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 05/15/09 13:36

no, i haven't abandoned....
let me say,... at the moment i have other things to do thirst.
but everyone is allowed to continue my work.

cu
Posted By: TrQuocAn

Re: 2.5D Spaceshooter - OpenSource - 06/13/09 11:01

I can't Down load your Demo laugh ?
Would you mind to share me how to Creat a Space Cube (Box) like this !
It's very nice laugh
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/08/09 06:57

Download the AUM.... i guess 83 or aum 82.
In the AUM-File u'll find the project.


I also have news:
I am working on a 3d-spacegame Template for 3dgs.
The 2.5D Version also will be continued (also a template-version).

If you are interested to help me (with coding, music, sound, model -creation), please contact me via PM.

cheers
Marcel
Posted By: Felixsg

Re: 2.5D Spaceshooter - OpenSource - 07/08/09 09:18

great template version

I wait this work
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/10/09 12:37

If you are interested, her is an old short video that show a lil' bit of my work.....


http://www.youtube.com/watch?v=RqMvX4Zhm8M


Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/16/09 11:05

To give you news about the status of the 2.5D and the 3d space-game project.

I have recoded my script to 90% and the code works perfect (for me).
I have included new functions, you can use to calculate a complete 3d move with only 3 instructions.

You can setup the spaceship (acceleration, friction, other forces, weight,and so on).

A little move-able start-menue is also inlcluded.

An alpha version of my star-field effect = included.

Now i am working on the alpha version of the npc-ai.
(an ai only for a little battle).

After i have finished this, i use the code of the 3d version for the 2.5d version, so you can understand the scipt a lot easier.


One mor thing to say:
Before i release this 2 contributions, i have to talk with george or / and jcl, cause i wanna "win" the pro version of 3dgs (i have the com. version yet).
I hope this is possible......
This weekend i'll create a short video, to demonstrate the project.


cu
Marcel
Posted By: Felixsg

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 07:19

If need to participate in a competition of the aum
and then the user can vote for you
but I not sure if you can use this later
now is a shader competition (if I'm not in a mistake)
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 07:36

Yes, u are right.
The running contest is a shader-contest.

But maybe i can send it to george, an tell him to use it for the next contest..... ?
but i still have no answere from george.... maybe he is on holiday.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 14:42

Ok, jcl answered my question.

So the easier way is to wait at the right contest.
The other way is,... the project must be very popular -> and with a "Space-Game" i guess..... this would not get very popular.
But if i would create a "dvd-workshop", how to script a project like this,...
maybe a lot of newbies would be interested in this....

I'll think about it.....

But the video of my project still will come next week.

cu
Marcel
Posted By: VeT

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 15:06

As the next contest would be shader-contest, newbies would wait too long for your contribution grin

Sorry, i didnt see Felixsg's reply smile
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 15:20

grin whistle

Well, after a short "brain-storming" sick ....
i have an idea:

the code for the space-game is also to use for other flight-simulations,... what do you think about this idea VeT..?
Posted By: VeT

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 15:36

Nice idea smile
You want to come to contest with pack of space- and flight-simulators? grin

Looking like you may add gravity, model of Earth and change skycubes :))))
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/17/09 20:18

yes..........
Posted By: SomebodyNew

Re: 2.5D Spaceshooter - OpenSource - 07/23/09 18:23

I just wanted to thank you for your efforts. Your 2.5d spacegame helped me understand a couple of things about lite-c.

I'd love to see the final version of this.
And good luck with that contest!
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 07/25/09 08:26

You are welcome!

the project will never get finished wink
..... its open Surce..... so there is always a way to continue the project.


i added a video on the project page.
But here is also a link to watch my video:

3D SpaceGame

I hope u enjoy it (sorry for the bad quality of the video, textures and uv's setup.....)

cheers
Marcel
Posted By: painkiller

Re: 2.5D Spaceshooter - OpenSource - 09/06/09 10:43

how is going the project?
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 10/05/09 14:34

Sorry for my late answere.....

the reason why i haven't continued the projects (2.5D and 3d Space-game):

- i have learned blender 2.49 (very intensive) with success
- i have learned java(me), and c# with 1/2 success laugh
- i am learning to write gamestudio-projects with c++

But today i'll continue the projects....


I hope some people have created their own version of the 2.5D spacegame during my learning-sessions laugh

cu
marcel
Posted By: painkiller

Re: 2.5D Spaceshooter - OpenSource - 10/05/09 19:49

I understand it maslone1 laugh , by the way, can you re-upload the last version?, because the links is broken
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 10/07/09 06:40

i will upload the latest version.

Do you know a good website to upload?
Posted By: archie

Re: 2.5D Spaceshooter - OpenSource - 10/07/09 08:02

Quote:
the links is broken

It is possible that a limited text-only copy of some version of the contribution might be found on the Gamestudio Wiki.
2.5D Spaceshooter V0_1x - OpenSource by maslone1

Quote:
Do you know a good website to upload?

Acknex Unlimited resources?

Posted By: painkiller

Re: 2.5D Spaceshooter - OpenSource - 10/07/09 14:54

Originally Posted By: maslone1
i will upload the latest version.

Do you know a good website to upload?


I upload my creations to filefront, but the files are deleted autocatically after x time without any download, if you don't prevent it.

I think you can upload it to mediafire, the donīt delete the files
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 10/09/09 18:24

thank you for that information
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 10/16/09 07:25

Hey there!

So i have continued this project, and i am also do little tests with it to find bugs. So i fixed some bugs. But i have a little war with one BUG.
If i delete the player-ship and the player- function + reload the player with the player-function during i press (any) key, the value for the key keeps "1" (True). So i have to press the key again (for short) to reset it.
That means for me:
i have to write an own function that gives the key information to the player-ship. But isn't there an easy way.

while(xxxx){
......
.....
....
wait(1);}
key_force.x = 0;

-> is not possible (i have tested it, and the bug is still there....)

So do you know this bug in your projects? Have you other ideas to fix this?
Posted By: painkiller

Re: 2.5D Spaceshooter - OpenSource - 10/17/09 14:22

I think if you open a new topic more people will see yor problem
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 01/28/10 18:02

..... laugh ok,..... so i have started this "open-source" for nothing... ? like nothing-need-this-source laugh

no one added some functions, created other versions...?
Posted By: MadMark

Re: 2.5D Spaceshooter - OpenSource - 04/19/10 00:25

Hey Maslone1,

My wife upgraded my software last Christmas to A7 Commercial, so I am pleased to find your codebase. Rather than try and re-write my old C-Script space game from scratch in Lite-C, I am attempting to learn Lite-C as I fiddle with your source. Thanks for making it available.

Can you tell me what I would need to do to change the camera from 850 quants above the ship to first person perspective? I have modified F_cam_one, but I'm sure the keystrokes and other stuff also need to be changed. Not sure where or to what values...

function Cam1()
{
var cam_goal_dist; //Variable for the camera-distance
camera.z = Ships[1].z + 50; // cam-starting position

while(1){

camera.x = Ships[1].x;
camera.y = Ships[1].y;

cam_goal_dist = Ships[1].x + 850 + facCamAbst;
if(camera.x < cam_goal_dist) { camera.x += 1.8; } // the cam position follow the calculated cam_goal_dist variable
if(camera.x > cam_goal_dist) { camera.x -= 1.2; }
camera.tilt= 0; // -90 = look down
camera.roll= -90; // -90 = look forward
camera.pan = 0; // -90 = look sideways

wait(1);
}
}
Mark
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 04/19/10 19:04

Hey MadMark!

Now the new changed code for you (and all other people):

Code:
function Cam1()
{
	
var cam_goal_dist = -40;					//Variable for the camera-distance
//camera.z = Ships[1].z + 850;		//thats the cam-starting position

camera.x = Ships[1].x;		//the x and y position is always the player x and y position
camera.y = Ships[1].y;
camera.z = Ships[1].z;	
	
while(1){	

rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));


if(key_u != 0) { cam_goal_dist += 2*time_step; }
if(key_i != 0) { cam_goal_dist -= 2*time_step; }


//camera.x = Ships[1].x;		//the x and y position is always the player x and y position
//camera.y = Ships[1].y;


/*
cam_goal_dist = Ships[1].z + 850 + facCamAbst;     // always the standard-distanze plus the variable distance
																	// how the variable-distance ist calculated you see in Pl_Ship.c

if(camera.z < cam_goal_dist) { camera.z += 1.8; }  // the cam position follow the calculated cam_goal_dist variable
if(camera.z > cam_goal_dist) { camera.z -= 1.2; }  // the reason why i use this: it brings more "dynamic" to the cam-movement
*/


camera.tilt= 0;
camera.roll= 0;
camera.pan = Ships[1].pan;


wait(1);	
 }
}




and the same code again, but this time without "nonsense":
Code:
function Cam1()
{
	
var cam_goal_dist = -40;					//Variable for the camera-distance

camera.x = Ships[1].x;		//the x and y position is always the player x and y position
camera.y = Ships[1].y;
camera.z = Ships[1].z;	
	
while(1){	

rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));

if(key_u != 0) { cam_goal_dist += 2*time_step; }
if(key_i != 0) { cam_goal_dist -= 2*time_step; }

camera.tilt= 0;
camera.roll= 0;
camera.pan = Ships[1].pan;


wait(1);	
 }
}




With the key " U " and " I " you can scroll / change the distance between camera and spaceship.
scroll down to "zero" and you have your 1person camera. or change the value "cam_goal_dist" to zero.

The important part is this function:
rotate_rel(camera.x, Ships[1].x, Ships[1].pan, vector(cam_goal_dist,0,0));

have a look at "F_math.c". there you see how ot calculates the position for the camera.


I hope it helps you.

But remember, thats simply the code for 2.5D. you cannot fly in complete 3d.

Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 04/23/10 06:10

Have u tested the code, madmarK?
Posted By: MadMark

Re: 2.5D Spaceshooter - OpenSource - 04/25/10 17:48

Yes, finally tested it. Cool. I'm liking it.
Sure would like to fly around in 3D though, with no limit on altitude. I'm trying to figure out a space flight simulator, so I need to get below "0 altitude".

Thanks for your help Maslone1.
Posted By: maslone1

Re: 2.5D Spaceshooter - OpenSource - 04/25/10 20:26

You mean a space-flight like this:
http://www.youtube.com/watch?v=hduDzJAla9I

old video....
... a lot of work....
but in some years.... maibe i will finish my project laugh
© 2024 lite-C Forums