Page 1 of 1

Split screen help

PostPosted: Sat Jun 04, 2011 10:31 am
by tzoli
Hi
I'm trying to make a game with split screen but if i shoot bullets they doesn't appears on the splited screen.
Please help!I use draw_from to make in split screen.

Re: Split screen help

PostPosted: Sat Jun 04, 2011 11:00 am
by schnellboot
try to be more precise pls

Re: Split screen help

PostPosted: Sat Jun 04, 2011 11:29 am
by jimmynewguy
I assume you're using speckford's splitscreen demo, in that case:

bullet -> create actor -> script editor
Code: Select all
bulletcount ++;

Makes it so we know how many bullets there are

bullet -> destroy actor -> script editor
Code: Select all
bulletcount --;

Still just lets us know how many bullets

viewP1 -> draw actor -> script editor
Code: Select all
int i;//needed for loop
erase(0, 0, 0, 1);

for(i=0; i < bulletcount; i++)//loop through all the bullets
{
Actor * this = getclone2("bullet", i);//so we can use pointers for x & y, can't do bullet.i.x
draw_from("bullet.i", 320+this->x-p1.x, 160+this->y-p1.y, 1);//draw that bullet
}


viewP2 -> draw actor -> script editor
Code: Select all
int i;
erase(0, 0, 0, 1);

for(i=0; i < bulletcount; i++)
{
Actor * this = getclone2("bullet", i);
draw_from("bullet.i", 320+this->x-p2.x, 160+this->y-p2.y, 1);
}

almost same thing as last code, but for viewP2

Global Code
Code: Select all
Actor * getclone2 ( char * actorName, long cloneNumber )
{

  char resultString[256] = "";
  char cloneNumberAsString[10];
  Actor * resultActor;

  strcpy ( resultString, actorName );
  strncat ( resultString, ".", 1 );
  sprintf (cloneNumberAsString, "%i", cloneNumber);
  strncat  ( resultString, cloneNumberAsString, 10 );

  resultActor = getclone(resultString);

  return resultActor;
}

Jazz_e_bob's awesome code so we can get the clone of the bullet in order to draw him

Re: Split screen help

PostPosted: Sat Jun 04, 2011 12:56 pm
by tzoli
Thanks :D

Re: Split screen help

PostPosted: Sat Sep 20, 2014 3:13 pm
by RippeR7420
Could someone go into detail about what this Global Code does? I sure would appreciate it :)
It sort of makes sense to me, But when I try to use it, it says "Error line 2: Illegal redefinition of builtin function getclone2".

Thanks in advance!

Re: Split screen help

PostPosted: Sat Sep 20, 2014 4:13 pm
by lcl
The Global Code part in that code is just a function to get access to single clones by their actor name and cloneindex. The reason why you get that error is that the 1.4.1 version of GE already has a built in getclone2-function, so you can't define a new function with the same name.

Re: Split screen help

PostPosted: Sat Sep 20, 2014 11:01 pm
by skydereign
And just so you know, that version of the getclone2 function in unnecessarily complex. It is using a bunch of str functions, first to set the resulting string, then concats a period, then uses sprintf to set another string with the cloneindex value, and then cat that onto the resultString. You could do all of that with one sprintf call. Here is the shorter version.
Code: Select all
Actor*
getclone2(char* actor_name, int c_index)
{
    char buffer[30];
    sprintf(buffer, "%s.%d", actor_name, c_index);
    return (getclone(buffer));
}

Re: Split screen help

PostPosted: Wed Dec 10, 2014 7:56 pm
by speckford123
Oh gosh, I forgot I made a splitscreen demo a while back
the memories, haha