|
|
Re: split-screen
[Re: Vladant]
#341983
09/22/10 13:18
09/22/10 13:18
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Hello and welcome!
You have to declare two separate views:
VIEW* view_split1 = { layer = 1; } VIEW* view_split2 = { layer = 1; }
function init_splitscreen() { set(view_split1,SHOW); set(view_split2,SHOW); reset(camera,SHOW);
view_split1.size_x = screen_size.x; view_split1.size_y = screen_size.y/2;
view_split2.size_x = screen_size.x; view_split2.size_y = screen_size.y/2; view_split2.pos_y = screen_size.y/2; }
Call this function at the end of your main-function. Now move these views independently, for instance by two player actions:
action player_one() { view_split1.genius = me; while(1) { my.pan += (key_a-key_d)*10*time_step; c_move(me,vector((key_w-key_s)*20*time_step,0,0)),nullvector,IGNORE_PASSABLE | GLIDE); vec_set(view_split1.x,my.x); vec_set(view_split1.pan,my.pan); wait(1); } }
action player_two() { view_split2.genius = me; while(1) { my.pan += (key_cul-key_cur)*10*time_step; c_move(me,vector((key_cuu-key_cud)*20*time_step,0,0)),nullvector,IGNORE_PASSABLE | GLIDE); vec_set(view_split2.x,my.x); vec_set(view_split2.pan,my.pan); wait(1); } }
Control player one with WASD, player two with the cursor keys.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: split-screen
[Re: Vladant]
#341984
09/22/10 13:22
09/22/10 13:22
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
As you can't speak much english, hopefully this should help:
#include <acknex.h>
#include <default.c>
VIEW* camera2 = { //create 2nd view
flags = SHOW;
}
void main(){
video_mode = 8;
wait(1);
camera.size_x = screen_size.x / 2 - 2; //make camera only 1/2 the size of the screen
camera2.size_x = screen_size.x / 2 - 2; //make camera2 only 1/2 the size of the screen
camera2.pos_x = screen_size.x / 2 + 4; //move camera2 over the the right side
level_load(NULL); //load a blank level
ent_create(CUBE_MDL, vector(50, 0, 0), NULL); //create an object just for a reference point
while(1){
camera.x += (key_w-key_s) * time_step; //move camera on W and S
camera2.x += (key_cuu-key_cud) * time_step; //move camera2 on cursorUp and cursorDown
wait(1);
}
}
and welcome!
|
|
|
Re: split-screen
[Re: Vladant]
#342055
09/22/10 23:24
09/22/10 23:24
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
Senior Member
|
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi, here is some code I am using to make a tank game.
#include <acknex.h>
#include <default.c>
ENTITY* blue_tank;
VIEW* camera2 =
{
pos_x = 0;
pos_y = 390;
pos_z = 0;
size_x = 1024;
size_y = 380;
flags = VISIBLE;
}
VIEW* camera1 =
{
pos_x = 0;
pos_y = 0;
pos_z = 0;
size_x = 1024;
size_y = 360;
flags = VISIBLE;
}
action blue_tank()
{
wait(1); c_updatehull(me,0);
while (1)
{
if((my.floor_dist=c_trace(me.x, vector(me.x,me.y,me.z-100), IGNORE_ME|USE_POLYGON)))
{ my.z -= my.floor_dist+my.min_z; } //crude gravity/floor-matching code
if (key_a)
my.pan += 3*time_step; // increase the pan angle of the car
if (key_d)
my.pan -= 3*time_step; // decrease the pan angle of the car
if (key_w )
c_move (my, vector(2*time_step, 0, 0), nullvector, GLIDE);
if (key_s )
c_move (my, vector(-2*time_step, 0, 0), nullvector, GLIDE);
wait (1);
vec_set(camera1.x,my.x);
vec_set(camera1.y,my.y);
vec_set(camera1.z,my.z-2);
vec_set(camera1.pan,my.pan);
}
}
action red_tank()
{
wait(1); c_updatehull(me,0);
while (1)
{
if((my.floor_dist=c_trace(me.x, vector(me.x,me.y,me.z-100), IGNORE_ME|USE_POLYGON)))
{ my.z -= my.floor_dist+my.min_z; } //crude gravity/floor-matching code
if (key_j)
my.pan += 3*time_step; // increase the pan angle of the car
if (key_l )
my.pan -= 3*time_step; // decrease the pan angle of the car
if (key_i )
c_move (my, vector(2*time_step, 0, 0), nullvector, GLIDE);
if (key_k )
c_move (my, vector(-2*time_step, 0, 0), nullvector, GLIDE);
wait (1);
vec_set(camera2.x,my.x);
vec_set(camera2.y,my.y);
vec_set(camera2.z,my.z-2);
vec_set(camera2.pan,my.pan);
}
}
function main()
{
level_load ("tmap.wmb");
wait (1);
ent_create("blue_tank.mdl", vector(-460, 460,10),blue_tank);
ent_create("red_tank.mdl", vector(460, -460,10),red_tank);
}
function init_startup()
{
wait (-1);
video_switch(8, 0, 0); // change the resolution to 1024 x 768 pixels
camera.flags &= ~VISIBLE; // now hide the default camera
// set the desired positions and angles for the 4 cameras
// settings for camera 2
vec_set (camera2.x, vector (0,0,0));
camera2.pan = 0;
camera2.tilt = 0;
camera2.roll = 0;
vec_set (camera1.x, vector (0,0,0));
camera1.pan = 0;
camera1.tilt = 0;
camera1.roll = 0;
}
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
|