Camera Shifting Focus Only on Two Fighters

maxman

Well-known member
I'm trying to have the camera shift focus only on two fighters. I put the screen in the middle where two fighters are and it's fine. Even when you move away after the fight starts, it looks like the camera is following both fighters. However, it's only focusing on the player by being the center while one opponent has his subject_to_screen 1 set.

Code:
anim follow20 #Remain Idle
@script
void self = getlocalvar("self");
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
int width = openborvariant("levelwidth")/2;
int PLAY = openborvariant("count_players");
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
if(frame == 0){
   if(findtarget(P1) || findtarget(P2)){
      changelevelproperty("scrollspeed", 0);
      changeopenborvariant("xpos", width);
      changeentityproperty(self, "aggression", 100);
   }
   /*if(PLAY == 2){
    killentity(self);
    loadmodel("no1");
    setspawnentry("name", "no1");
     setspawnentry("alias", "_");
    setspawnentry("coords", 0, 200, 0);
    setspawnentry("health", 1);
    //void e = spawn();
    //changeentityproperty(e, "direction", 0);
    clearspawnentry();

    if(P1){
        setglobalvar("Fighter1", P1);
        changeentityproperty(P1, "position", width-70, z, 0); // Spawn player 1 in a specific position
        changeentityproperty(P1, "direction", 1); //Face left, direction 0 for left and 1 for right
        changeentityproperty(P1, "candamage", openborconstant("TYPE_PLAYER"));
    }

    if(P2){
        setglobalvar("Fighter2", P2);
        changeentityproperty(P2, "position", width+70, z, 0); // Spawn player 2 in a specific position
        changeentityproperty(P2, "direction", 0); //Face left
        changeentityproperty(P2, "candamage", openborconstant("TYPE_PLAYER"));
    }
   }*/
}

@end_script
    offset 307 297
    delay 2
    loop 1 1
    frame data/CHARS/Eagle/Eagle_0-0.png
    delay 10
    frame data/CHARS/Eagle/Eagle_0-0.png
    frame data/CHARS/Eagle/Eagle_0-1.png
    frame data/CHARS/Eagle/Eagle_0-2.png
    frame data/CHARS/Eagle/Eagle_0-3.png
    frame data/CHARS/Eagle/Eagle_0-4.png
    frame data/CHARS/Eagle/Eagle_0-5.png
    frame data/CHARS/Eagle/Eagle_0-6.png
    frame data/CHARS/Eagle/Eagle_0-7.png
    frame data/CHARS/Eagle/Eagle_0-8.png
    frame data/CHARS/Eagle/Eagle_0-9.png
    frame data/CHARS/Eagle/Eagle_0-10.png
    frame data/CHARS/Eagle/Eagle_0-11.png

This is the camera itself.

Code:
name camera
type none
speed 10



anim idle
@script
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int hres = openborvariant("hresolution"); // Screen
    int width = openborvariant("levelwidth"); // Screen2
    int xpos = openborvariant("xpos");
    int ypos = openborvariant("ypos");
    int vres = openborvariant("vresolution");
    int PLAY = openborvariant("count_players");
    int CountEnem = openborvariant("count_enemies");
    int x; int y;
    x = xpos+hres/2;
    y = ypos+vres/2;
    int enemy_cursor = 0; void enemy_entity = NULL();

/*    for(enemy_cursor = 0; enemy_cursor < CountEnem; enemy_cursor++){
       
    }*/

    if(PLAY == 2 && hres && getglobalvar("Wait")==NULL()){
        //changelevelproperty("scrollspeed", x+y);
        changelevelproperty("scrollspeed", (x+21)+y);
    }
    if( (P1 || P2) && PLAY == 1 && hres && getglobalvar("Wait")==NULL()){
        //changeopenborvariant("xpos", (hres/2)+30);
        changeopenborvariant("xpos", (width/2)-160);
        //changeopenborvariant("xpos", (width/2));
    }
    /*if(P1 && PLAY == 1 && hres && getglobalvar("Wait")==NULL()){
        //changeopenborvariant("xpos", (hres/2)+30);
        changeopenborvariant("xpos", (width/2)-160);
    }
    if(P2 && PLAY == 1 && hres && getglobalvar("Wait")==NULL()){
        //changeopenborvariant("xpos", (hres/2)+30);
        changeopenborvariant("xpos", (width/2)-160);
    }*/

@end_script
    loop 0
    delay 3 #82 # 3
    offset 1 1
    frame data/chars/misc/empty.gif
    #delay 386
    frame data/chars/misc/empty.gif
    #@cmd changeentityproperty getlocalvar("self") "animation" openborconstant("ANI_FOLLOW1")
    frame data/chars/misc/empty.gif


anim follow1
@script
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void T1 = findtarget(P1);
    void T2 = findtarget(P2);
    int Screen = openborvariant("hresolution");
    int Screen2 = openborvariant("levelwidth");
    int xpos = openborvariant("xpos");
    int ypos = openborvariant("ypos");
    int vres = openborvariant("vresolution");
    int PLAY = openborvariant("count_players");
    int x; int y;
    x = xpos+Screen/2;
    y = ypos+vres/2;

    if(PLAY == 2 && Screen2 && getglobalvar("Wait")==NULL()){
        changelevelproperty("scrollspeed", x+y);
        //changelevelproperty("scrollspeed", (x+21)+y);
    }
    if( ( (P1 && T1)|| (P2 && T2) ) && PLAY == 1 && Screen && getglobalvar("Wait")==NULL()){
        changeopenborvariant("xpos", (Screen2/2));
    }

@end_script
    loop 0
    delay 3 #82 # 3
    offset 1 1
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif

Opponent's stage:
Code:
#### PLEASE USE BOTH THESE IMAGES AS HUD FOR YOUR PLAYER(S) UNLESS IT'S BONUS STAGE #######
fglayer data/sprites/hud_base.png -1 1 0 3 3 1 1 1 1 1 0 0 0 0 0 0
fglayer data/sprites/hud.png -1 1 0 3 3 1 1 1 1 1 0 0 0 0 0 0
###########################################################################################

bglayer        data/bgs/eagle/1_0-0.png 0.085 0 0 -54 1 1 1 1 0 0
bglayer        data/bgs/eagle/1_1-0.png 0.17 0 453 -79 1 1 1 1 1 0
#background/bglayer path xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency alpha
panel        data/bgs/eagle/1_2-0.png
#fglayer        data/bgs/eagle/1_3-0.png 50 0 0 317 16 1 1 1 1 1 0 0 0 0
#frontpanel    data/bgs/eagle/1_3-0.png
#fglayer path z xratio zratio xposition zposition xspacing zspacing xrepeat zrepeat transparency amplitude wavelength wavespeed bgspeedratio

direction        both
settime 0
notime 1
order        a
#cameratype 1
#cameraoffset 0 -224
#scrollspeed 0

levelscript data/levels/levelfight.c

#load Ryu_Icon 30

light    -256 -128
at    0

#spawn darkblue
#@script
void main(){
    void entity = getlocalvar("self");
    int width = openborvariant("levelwidth")/2;
    int height = openborvariant("levelheight")/2;
    changeentityproperty(entity, "position", width, 500, 0);
}
@end_script
#coords 0 500
#at 0

#spawn darkblue
#coords 391 200
#at 0

spawn empty 1
@script
void main(){
    setglobalvar("Return", "Stage_Eagle");
}
@end_script
coords 0 400
at 0

spawn    barricade 1
@script
void main(){
    changeentityproperty(getlocalvar("self"), "position", 381, 244, 0);
}
@end_script
coords    381 244
at    0

spawn   empty 1
@script
void main()
{
    int P1 = getplayerproperty(0, "entity"); //Calling player 1 entity
    int P2 = getplayerproperty(1, "entity"); //Calling player 2 entity

    //changelevelproperty("scrollspeed", 0);
    void self = getlocalvar("self"); //Get calling entity.
    int width = openborvariant("levelwidth");
    int half = width/2;
    int hres = openborvariant("hresolution");
    int xpos = openborvariant("xpos");

    if(P1){
      changeentityproperty(P1, "position", half-70, 200, 0); // Spawn player 1 in a specific position
      changeentityproperty(P1, "direction", 1); //Face left, direction 0 for left and 1 for right
    }
    if(P2){
      changeentityproperty(P2, "position", half+70, 200, 0); // Spawn player 2 in a specific position
      changeentityproperty(P2, "direction", 0); //Face left
//      changeentityproperty(P2, "health", 1);
    }
    changeopenborvariant("xpos", half+70); // Calling the x value point
}
@end_script
coords   0 200
at   0

#music    data/music/eagle.ogg 1382535#31.350 * 44100 = 1382535
#at              110

spawn    camera 1
@script
void main(){
    void self = getlocalvar("self");
    int width = openborvariant("levelwidth")/2;
    changeentityproperty(self, "position",width, -5, 0);
}
@end_script
coords 0 200
at 0

spawn    1vs1 1
#spawn EagleE
@script
  #import "data/scripts/aimove.c"
  void main()
  {
    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity"); // Get player 1
    int P2 = getplayerproperty(1, "entity");
    int map = getentityproperty(self, "map");
    int x = getentityproperty(self, "x");
    int y = getentityproperty(self, "y");
    int PLAYS = openborvariant("count_players");
//    setglobalvar("Fighter1", P1); // fill Fighter1 variable with player 1
//    changeentityproperty(P1, "setlayer", 200);
//    setglobalvar("Fighter2", self); // fill Fighter2 variable with this enemy
    int width = openborvariant("levelwidth");
    int half = width/2;
    void e;
//    changelevelproperty("scrollspeed", 0);
   
//    setAIMove("nomove chase wander");
//    changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW20"));
//    setidle(self, openborconstant("ANI_IDLE"),1);


    if(P1){
       setglobalvar("Fighter1", P1);
       changeentityproperty(P1, "position", half-70, 200, 0);
       changeentityproperty(P1, "direction", 1);
    changeentityproperty(P1, "health", 1);
       setglobalvar("Fighter2", self);
       changeentityproperty(self, "position", half+70, 200, 0);
       changeentityproperty(self, "direction", 0);
       changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2")); // Eagle (enemy type)
    }
    if(P2){
       setglobalvar("Fighter2", P2);
       changeentityproperty(P2, "position", half+70, 200, 0);
       changeentityproperty(P2, "direction", 0);
       setglobalvar("Fighter1", self);
       changeentityproperty(self, "position", half-70, 200, 0);
       changeentityproperty(self, "direction", 1);
       changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2")); // Eagle (enemy type)
    }

    //changeopenborvariant("xpos", 300); // Calling the x value point
  }
@end_script
health 100
#alias Eagle
coords    0 200 0
at    0

spawn   Rounds 1
@script
void main(){
    void self = getlocalvar("self");
    int width = openborvariant("levelwidth")/2;
    changeentityproperty(self, "position", width-5, 100+16, 50);
}
@end_script
coords  0 400 40
at    0

#spawn no1 1
#coords 0 200
#at 0

spawn RefPlays 1
coords 160 200
at 0
 
Last edited:
If you had registered both fighters like I do in Versus module, you could acquire both fighter's coords then adjust camera's position based on that. And you don't need to force any fighters to subject to screen.
Regardless of the method, there's one issue the camera could face: both fighter create wide distance between them and the distance is wider than screen's width (cause the field is wider than screen). I'm not sure how to solve this. Maybe zooming out could do it :unsure:.
 
If you had registered both fighters like I do in Versus module, you could acquire both fighter's coords then adjust camera's position based on that. And you don't need to force any fighters to subject to screen.
Regardless of the method, there's one issue the camera could face: both fighter create wide distance between them and the distance is wider than screen's width (cause the field is wider than screen). I'm not sure how to solve this. Maybe zooming out could do it :unsure:.
zooming in or out is the answer, but the levels have to be designed for that in mind.
there are other aestetic challenges, like figuring out how to do an openbor equivalent to "zoom delta" (mugen)
& what to do about the bboxes, hitboxes -
i was talking about this precise "zoom troubles" with @O Ilusionista , since i was wondering if Ikemen's /Mugen's method of rezising the panel and entities simultaneously could be adapted to Openbor -
from what i can see so far , Ikemen utilizes a zooming method that also takes care of the "BOxes" in a much more smooth fashion than samurai showdown does.

there is also the fact that a level limit has to be set, otherwise things can zoom out so far the main characters will look like ants....

My edited levels in Ikemen behave like Killer instinct/smash brothers, the zoom in our out, have very long distances
mqdefault.jpg

or very limited
1667245034162.jpeg
 
To further explain what I told to @oldyz :
There are two different types of scalling in mugen/Ikemen - stage zoom and angledraw.

The first one is applied in the whole stage and, yes, it scales everthing - including the clsn boxes (attackbox or bbox in OpenBOR). Remember the Samurai Shodown styled zoom? That is it, but works for all collision boxes.

The second one is a code you can aply to rotate and/or scale something in mugen (you can do it on the AIR file in 1.1 too) but that doesn't scale or rotate anything, just the sprite.
 
@oldyz, once again you are overthinking things. Now that I see what you are guys are going for, let me also explain a bit.

Yes, there are two kinds of zoom. For sake of standardization, let's call them Object Zoom, and Screen Zoom. Just like Mugen, OpenBOR can do both (and any other draw effect - rotation, distortion, etc.).

Object Zoom is when you zoom specific objects on screen. This early prototype from Lucia's Run is an example of object zooming. Lucia and the trees zoom, the overall viewpoint does not.


Screen Zoom is when you zoom the viewpoint. Early SNK Fighters and the closeups in @O Ilusionista's Avengers module are the best examples I can recall at the moment.

Now, these two types of zooming are very different, and pose very different challenges. First, Screen Zoom.

yes, it scales everthing - including the clsn boxes (attackbox or bbox in OpenBOR). Remember the Samurai Shodown styled zoom? That is it, but works for all collision boxes.

I seriously doubt Mugen is actually scaling collision or anything else on full screen zoom. That would be a huge waste of resources because it doesn't need to. Collision, jumping, distance and all that take care of themselves when you scale an entire screen. It's the same for OpenBOR. You can zoom the whole screen in or out as much as you want and the game mechanics don't change a bit. Zooming in is just about as simple as it gets. Pick a point on screen, zoom in, and you're done.

Zooming out (as you already seem to understand) is where the challenge lies. On a sheer technical level, it isn't all that hard. When you you zoom in, you start with a sub-screen at least exactly as large as the main screen, then change its drawmethod to scale up. For zooming out, you just do it in reverse. Your sub-screen needs to start at the size of the main screen + whatever amount you plan to zoom out. Ex: In a 480*272 module that you want to zoom out to 50% and assuming no offset adjustment, your sub-screen starts at 720*408. Then you can shrink it down to 50% without it becoming a picture in picture.

That hard part is that you have to plan your level to accommodate the zoom out so you don't wind up with blank areas from zooming out too far. You can also take a page from SNK. If you pay close attention, you'll notice they also pan the screen up and down when zooming to maintain relatively consistent positions without having that much extra vertical area in the stage.

Object Zoom is when the issue with collision comes into play. I only spoke of the Neo-Geo in my explanations about how SNK dealt with collision because the Neo-Geo doesn't have screen zoom. They had to do it with very carefully planned object zoom on everything, which of course does create challenges with collision. In OpenBOR and Mugen, you don't have that limitation. Unless you are intentionally using object zoom, you don't have to worry about game mechanics at all.

I'll try to build an exhibition module to show full screen transformations when I get some time. It's really much eaiser than all this text makes it seem.

DC
 
@DCurrent

as far as i understood from your explanation, it seems that your possible demo can manage a zoom in and out effect of an entire flat plane, where everything grows or shrinks.

that gets me thinking that mugen/ikemen is using
a subscreen method of sorts that seems to allow transparency and or alpha channel, which makes the illution that the panel & player entities zoom in and out very smoothly with no "distortions" or bugs on the 'Boxes" and at the same time giving it a "layer" aestetic

this would also allow for a multiplane zoom effect of the "FGlayers" with different zoom rates & values in relation to their "delta" values

either way, i need to prepare an Ikemen demo and a mugen demo for those curious enough to analize and test, not many mugen/ikemen modules feature the type of 4 player "multiplane" zoom i was aiming for, and unfortunately Ikemen is broken and interprets the values a bit wonky and backwards, the last time i tested zoomdelta/ multiplane zoom experiments on mugen , the values did not seem to work at all.

to further illustrate, here is an old version of the zoomdelta/multiplane zoom concept courtesy of Uncle Walt
 
Last edited:
@DCurrent

as far as i understood from your explanation, it seems that your possible demo can manage a zoom in and out effect of an entire flat plane, where everything grows or shrinks.

that gets me thinking that mugen/ikemen is using
a subscreen method of sorts that seems to allow transparency and or alpha channel, which makes the illution that the panel & player entities zoom in and out very smoothly with no "distortions" or bugs on the 'Boxes" and at the same time giving it a "layer" aestetic

this would also allow for a multiplane zoom effect of the "FGlayers" with different zoom rates & values in relation to their "delta" values

I don't know how Mugen does screen zooming, but I'm pretty sure it does not have definable sub-screens like OpenBOR. From from what @O Ilusionista describes, it probably runs everything through a final output filter with various attributes you can adjust. In OpenBOR terms, you could think of it as a single static sub-screen.

As for smoothness, that's up to the algorithm. Just to compare:
  • Neo-Geo: Reduce only, done by skipping certain pixel lines. The result is like a nearest-neighbor algorithm, but there’s no real calculation. The skipping is hard coded onto the chip as a lookup table. The ranges are 0-255 (full size) vertical and 0-15 (full size) horizontal.
  • OpenBOR: Applies applies a nearest-neighbor formula from 0 to infinite on either axis. 256 is full size, so you have 255 levels of reduction. Note the text based scale parameters accept a decimal value, but the engine converts to a whole value: scale = trunc(<your decimal value> * 256).
  • Mugen/Ikemen: Again I can't say for sure but I believe Mugen has Bicubic resampling. Mugen accepts a decimal value, but I would just about guarantee it's doing the same thing as OpenBOR under the hood. IOW, 255 levels of reduction and infinite enlargement.
either way, i need to prepare an Ikemen demo and a mugen demo for those curious enough to analize and test, not many mugen/ikemen modules feature the type of 4 player "multiplane" zoom i was aiming for, and unfortunately Ikemen is broken and interprets the values a bit wonky and backwards, the last time i tested zoomdelta/ multiplane zoom experiments on mugen , the values did not seem to work at all.

to further illustrate, here is an old version of the zoomdelta/multiplane zoom concept courtesy of Uncle Walt

Crawl before you walk dude. You don't even know how to do single plane zoom yet and multi-plane zoom is a whole new ballgame. If the Mugen clones don't have definable sub-screens, then you're back to object zoom to get it done. That's going to be an absolute nightmare and frankly way beyond your current skill level.

OpenBOR can make it happen with sub-screens, but from your post you really don't understand what they are or how they work, so right now it's just not something you can do. You're going to have to master the sub-screen system to the point you understand how to capture portions of the main screen at various Z positions all at once. Then resize them at different rates in real time.

Again, crawl before you walk. Try out a basic full screen single-plane zoom first. When you can do that, then you can look into multi-plane.

@maxman,

Sorry for all the derailing. I do think a full screen zoom out is the way to go, but it does need a limiter. You don't want characters able to go so far away they wind up 1 pixel tall on the screen. I suggest you use an onmovex event to track distance of the farthest two characters you care about, and then all you need to do is apply an X position change to prevent them going furhter. That's how the engine handles screen and Z borders.

C:
/*
* First calculate the position boundary based on how far
* away you want to allow entities from each other.
*
* Then run this code to prevent escaping.
*/

if(x_pos > max_x_pos)
{
     changentityproperty(<entity>, "x", max_x_pos);
}
if(x_pos < min_x_pos)
{
     changentityproperty(<entity>, "x", min_x_pos);
}

HTH,
DC
 
Last edited:
I'm back. I tried zooming out by using the zoomout entity, but I cannot since the panel's height size is 244. I also tried modifying the numbers from 260 and below, but I got a crash.

Code:
name     zoomout
type     none
#subtype  noskip
setlayer 999
shadow     0

anim idle
loop      0
delay     2
offset    0 0
frame     data/chars/misc/empty.gif
@cmd setglobalvar "zoomentity" getlocalvar("self")
@cmd setglobalvar "zoomx" -180
@cmd setglobalvar "zoomy" -180
#@cmd setglobalvar "zoomvalue" 360

@cmd setglobalvar "zoomvalue" 360
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 350
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 340
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 330
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 320
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 310
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 310
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 300
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 290
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 280
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 270
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomvalue" 260
   frame   data/chars/misc/empty.gif
@cmd setglobalvar "zoomentity" NULL()
   frame   data/chars/misc/empty.gif
@cmd   killentity getlocalvar("self")
   frame   data/chars/misc/empty.gif

updated.c:
C:
void main(){
    zooming();
}

void zooming(){
   if(getglobalvar("zoomentity"))
   {
      zoom();       
   }
}

void zoom()
{
   void vscreen = openborvariant("vscreen");
   int maxz=openborvariant("PLAYER_MAX_Z")+1000;
   int zoom_value=getglobalvar("zoomvalue");
   int zoom_x=getglobalvar("zoomx");
   int zoom_y=getglobalvar("zoomy");
   void ent=getglobalvar("zoomentity");
   int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
   int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos"); //- getentityproperty(ent,"a");
   void zoom_scr = getglobalvar("zoomscreen");
   if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
   }
   clearscreen(zoom_scr);

   //draw what we need
   drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
   //setup drawMethod
   changedrawmethod(NULL(),"reset",1);
   changedrawmethod(NULL(),"enabled",1);
   changedrawmethod(NULL(),"scalex",zoom_value);
   changedrawmethod(NULL(),"scaley",zoom_value);
   changedrawmethod(NULL(),"centerx",px);
   changedrawmethod(NULL(),"centery",py);
   //Draw the resized customized screen to main screen.
   drawscreen(zoom_scr,px,py, maxz+1);
   changedrawmethod(NULL(),"enabled", 0);
   drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
   drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
   clearspriteq();
}

Dunno how to zoom out the whole stage, but I'm trying to limit the screen edge boundaries between fighters' positions. However, I'm lost. I did try adding some numbers in both xpos and scrollminx but I got weird results. Still, the camera pans towards only the player. Here I leave some notes as I was calculating for xpos, scrollminx, and scrollmaxx.

C:
void main(){
/*
* First calculate the position boundary based on how far
* away you want to allow entities from each other.
*
* Then run this code to prevent escaping.
*/

/*
screen res: 320 / 2 = 160; 160 - 70 = 90; 160 + 70 = 230; 230+90=320; 90-90=0;

panel:
example: ryu's stage
panel size image dimension: 664x244
width divided by half = half side positions for segregation;
664 / 2 = 332; 332 - 70 = 262; 332 + 70 = 402; 402 + 262 = 664; 262 - 262 = 0;
player 1 / enemy 2: 262 - 160 = 102; 262 + 160 = 422;
player 2 / enemy 1: 402 + 160 = 562; 402 - 160 = 262;
*/

    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int hres = openborvariant("hresolution");
    int x_pos = openborvariant("xpos");
    int min_x_pos = openborvariant("scrollminx");
    int max_x_pos = openborvariant("scrollmaxx");

    if(x_pos > max_x_pos - 230) // xpos farther than scrolling max? 
    {
         changeentityproperty(self, "x", max_x_pos - 230);
    }
    if(x_pos < min_x_pos)
    {
         changeentityproperty(self, "x", min_x_pos);
    }

}

Every time I put a value to any variables like x_pos and max_x_pos, the opponent switches to different places according to what's coded. However, I have no clue how scrollminx and scrollmaxx work. scrollminx scrolls from left to right and scrollmaxx scrolls from right to left, right? Isn't it almost like scrollx where the level scrolls with how many pixels to move?

(I want to zoom out the whole stage, but I don't know what to do.)
 
Here is my onmovex script along with the video where the enemy character "teleports" to its certain position via screen in level. Yes, I added hres alongside x_pos where max_x_pos is. 😳

C:
void main(){
/*
* First calculate the position boundary based on how far
* away you want to allow entities from each other.
*
* Then run this code to prevent escaping.
*/

/*
screen res: 320 / 2 = 160; 160 - 70 = 90; 160 + 70 = 230; 230+90=320; 90-90=0;

panel size:
example: ryu's stage
panel size:664x244
width divided by half = half side positions for segregation;
664 / 2 = 332; 332 - 70 = 262; 332 + 70 = 402; 402 + 262 = 664; 262 - 262 = 0;
player 1 / enemy 2: 262 - 160 = 102; 262 + 160 = 422;
player 2 / enemy 1: 402 + 160 = 562; 402 - 160 = 262;
*/

    void self = getlocalvar("self");
    int x = getentityproperty(self, "x");
    int hres = openborvariant("hresolution");
    int x_pos = openborvariant("xpos");
    int min_x_pos = openborvariant("scrollminx");
    int max_x_pos = openborvariant("scrollmaxx");

    if(x_pos + hres > max_x_pos)
    {
         changeentityproperty(self, "x", max_x_pos);
    }
    if(x_pos < min_x_pos)
    {
         changeentityproperty(self, "x", min_x_pos);
    }

}


Also, the enemy's unmoving prebattle animation here. Yes, I used scrollspeed 0 for stopping the scroll, but I wanna make the camera center.

Code:
anim    follow20 #remain idle
@script
void self = getlocalvar("self");
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
int width = openborvariant("levelwidth")/2;
int PLAY = openborvariant("count_players");
if(frame == 0){
   if(findtarget(P1) || findtarget(P2)){
      changelevelproperty("scrollspeed", 0);
      changeopenborvariant("xpos", width);
      //changeentityproperty(self, "aggression", 100);
   }
}
@end_script
    loop    1 1
    delay    2
    offset    25 99
    bbox    0 0 52 103
    frame    data/chars/ryu/0000000000.gif
    delay   9
    frame    data/chars/ryu/0000000000.gif
    offset    25 97
    frame    data/chars/ryu/0000000001.gif
    offset    25 99
    frame    data/chars/ryu/0000000002.gif
    offset    25 102
    frame    data/chars/ryu/0000000003.gif
    frame    data/chars/ryu/0000000004.gif
    offset    25 100
    frame    data/chars/ryu/0000000005.gif

 
Back
Top Bottom