Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Baklazhan, Ayumi, Hanky27), 1,387 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 8 1 2 3 4 5 6 7 8
2.5D Spaceshooter - OpenSource #238296
11/26/08 12:37
11/26/08 12:37
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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

Last edited by maslone1; 11/26/08 12:37.

A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #238301
11/26/08 13:09
11/26/08 13:09
Joined: Apr 2008
Posts: 437
dracula Offline
Senior Member
dracula  Offline
Senior Member

Joined: Apr 2008
Posts: 437
Hey, great idea !

Well done

Drac.

Re: 2.5D Spaceshooter - OpenSource [Re: dracula] #238316
11/26/08 15:55
11/26/08 15:55
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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

Last edited by maslone1; 11/26/08 15:57.

A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #238348
11/26/08 20:34
11/26/08 20:34
Joined: Nov 2008
Posts: 24
Nevada, USA
Kevinper Offline
Newbie
Kevinper  Offline
Newbie

Joined: Nov 2008
Posts: 24
Nevada, USA
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

Last edited by Kevinper; 11/26/08 20:35. Reason: added link

Kevin
Re: 2.5D Spaceshooter - OpenSource [Re: Kevinper] #238451
11/27/08 14:36
11/27/08 14:36
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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


A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #238947
12/01/08 11:28
12/01/08 11:28
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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


Last edited by maslone1; 12/01/08 11:33.

A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #240727
12/12/08 06:57
12/12/08 06:57
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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


A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #240728
12/12/08 07:07
12/12/08 07:07
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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


A8c, Blender, FlStudio, Unity3d
Re: 2.5D Spaceshooter - OpenSource [Re: maslone1] #240808
12/12/08 18:40
12/12/08 18:40
Joined: Apr 2008
Posts: 437
dracula Offline
Senior Member
dracula  Offline
Senior Member

Joined: Apr 2008
Posts: 437
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.

Re: 2.5D Spaceshooter - OpenSource [Re: dracula] #240821
12/12/08 19:46
12/12/08 19:46
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline OP
Senior Member
maslone1  Offline OP
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
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


Last edited by maslone1; 12/12/08 20:00.

A8c, Blender, FlStudio, Unity3d
Page 1 of 8 1 2 3 4 5 6 7 8

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

Gamestudio download | chip programmers | 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