Jump to content

Photo

Z3 Scrolling Preview (2.55) (bare bones)


  • Please log in to reply
3 replies to this topic

#1 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 30 September 2021 - 09:21 PM

Anybody want too see some Z3 scrolling? (Its not complete but I manage to stitch it together to create something to show off, though very BARE bones): https://www.dropbox....-40-19.mp4?dl=0

Dmap Script (Scrolling):

//Constants.
const int CAMERA_VIEW_WIDTH = 256;  //The camera viewport width (DON'T CHANGE THIS).
const int CAMERA_VIEW_HEIGHT = 256; //The camera viewport height (DON"T CHANGE THIS).
const int AUTO_ROOM_ID = -1;        //Used this in place of roomID in RoomInit() if you want to guess what room your in based on the screen your in.
const int START_DMAP = 0;           //The Dmap to start the game with.
const int START_SCREEN = 99;       //The screen to start on when the game starts.

//Bitmaps used to draw stuff.
bitmap CameraView; //The bitmap that the player sees.
bitmap Z3Room;     //The bitmap where the room is drawn on too.

//Camera Variables.
int CameraX = 0;
int CameraY = 0;

//Room Variables.
int RoomID = 0;                   //The Id of the room.
int RoomX = 0;                    //The X position of the room relative to the map. (Top-left)
int RoomY = 0;                    //The Y position of the room relative to the map. (Top-left)
int RoomWidth = 0;                //The width of the room in pixels.
int RoomHeight = 0;               //The height of the room in pixels.
int CurrentDMap = START_DMAP;     //The current dmap that the player is on. (the player is going to be frozen)
int CurrentScreen = START_SCREEN; //The current screen that the player is on. (the player is going to be frozen)
int ScreenArray[128];             //The array to hold the screens to be used in creating a room.
int RoomTopLeftScreen;            //The top left screen of the room where to start rendering.

//Call this once through at the start of the game (or every time the game is load)
void Z3ScrollingInit()
{
    CameraView = Game->CreateBitmap(CAMERA_VIEW_WIDTH, CAMERA_VIEW_HEIGHT);
}

//Initalize a room.
void RoomInit(int roomArray, int rmID, int entryScreen)
{
    //If room id is -1 then we have to guess what id it is based on our startScreen.
    if (rmID == -1)
    {
        
    }
    else
    {
        //Get the current dmap type.
        dmapdata dm = Game->LoadDMapData(CurrentDMap);
        int type = dm->Type;

        if (type == DMAP_DUNGEON)
        {
            RoomID = rmID;          //Set the Room ID.           
            int TempRoomX1;         //A temporary variable to hold the x1 position of the room.
            int TempRoomY1;         //A temporary variable to hold the y1 position of the room.
            int TempRoomX2;         //A temporary variable to hold the x2 position of the room.
            int TempRoomY2;         //A temporary variable to hold the y2 position of the room.
            int ArrayIncrement = 0; //The increment used to go through the screen array.

            //Loop through the dmap and construct our room.
            for (int i = 0; i < 64; i++)
            {
                int ScreenID = 0;              //The ID of the screen we are currently on.
                int ArrayEntry = roomArray[i]; //The array entry that contains the room id that the screen is associated with.

                if (ArrayEntry == rmID)
                {
                    if (ArrayIncrement == 0)
                    {
                        //Setup the width and height of the room.
                        TempRoomX1 = SCREEN_W * (i % 8);
                        TempRoomY1 = SCREEN_H * Floor(i / 8);
                        TempRoomX2 = SCREEN_W * ((i % 8) + 1);
                        TempRoomY2 = SCREEN_H * (Floor(i / 8) + 1);

                        RoomTopLeftScreen = i + (8 * Floor(i / 8));
                    }
                    else if (ArrayIncrement > 0)
                    {
                        //Update the x1 and/or x2 or the room.
                        if ((SCREEN_W * (i % 8)) < TempRoomX1)
                        {
                            TempRoomX1 = SCREEN_W * ((i % 8) - 1);
                            RoomTopLeftScreen = i + (8 * Floor(i / 8));
                        }
                        else if ((SCREEN_W * ((i % 8) + 1)) > TempRoomX2)
                        {
                            TempRoomX2 = SCREEN_W * ((i % 8) + 1);
                        }

                        //Update the y2 of the room.
                        TempRoomY2 = SCREEN_H * (Floor(i / 8) + 1);
                    }

                    ScreenID = i + (8 * Floor(i / 8));
                    ScreenArray[ScreenID] = ScreenID;
                    ArrayIncrement++;
                }
            }

            //Set the room dimensions.
            RoomX = TempRoomX1;
            RoomY = TempRoomY1;
            RoomWidth = TempRoomX2 - TempRoomX1;
            RoomHeight = TempRoomY2 - TempRoomY1;

            //Creating a Room Bitmap based on the dimensions defined.
            Z3Room = Game->CreateBitmap(RoomWidth, RoomHeight);
        }
        else if (type == DMAP_OVERWORLD)
        {
            
        }
        else if (type == DMAP_CAVE)
        {
            
        }
        else if (type == DMAP_BSOVERWORLD)
        {
            
        }
    }
}

void ScrollingEngineUpdate()
{
    if (RoomWidth == 256 && RoomHeight == 176)
    {
        //Initalize some variables.
        dmapdata dm = Game->LoadDMapData(CurrentDMap);
        int CurrentMap = dm->Map;

        //Draw the singular screen to the bitmap and blit it to the screen.
        CameraView->ClearToColor(0, 0x0F);
        CameraView->DrawScreen(6, CurrentMap, CurrentScreen, 0, 0, 0);
        CameraView->FastTile(6, HeroX, HeroY, HERO_WALK_DOWN_SPRITE, 6, 128);
        CameraView->Blit(6, RT_CURRENT, 0, 0, 256, 256, 0, 0, 256, 256, 0, 0, 0, 0, 0, false);
    }
    else
    {
        //Initalize some variables.
        dmapdata dm = Game->LoadDMapData(CurrentDMap);
        int CurrentMap = dm->Map;

        int RoomScreenWidth = RoomWidth / SCREEN_W;
        int RoomScreenHeight = RoomHeight / SCREEN_H;
        int RoomArraySize = RoomScreenWidth * RoomScreenHeight;

        //Clear the Bitmaps.
        Z3Room->ClearToColor(0, 0x0F);
        CameraView->ClearToColor(0, 0x0F);

        //Draw the room.
        for (int i = 0; i < RoomArraySize; i++)
        {
            int ArrayEntry = (RoomTopLeftScreen + (i % RoomScreenWidth)) + (16 * Floor(i / RoomScreenWidth));
            int RoomScreenID = ScreenArray[ArrayEntry];

            if (RoomScreenID != 0)
            {
                int ScreenX = SCREEN_W * (i % RoomScreenWidth);
                int ScreenY = SCREEN_H * Floor(i / RoomScreenHeight);

                Z3Room->DrawScreen(6, CurrentMap, ArrayEntry, ScreenX, ScreenY, 0);
            }
        }

        //Draw the player and blit the screen.
        Z3Room->FastTile(6, HeroX, HeroY, HERO_WALK_DOWN_SPRITE, 6, 128);
        CameraView->BlitTo(6, Z3Room, HeroX, HeroY, 256, 256, 0, 0, 256, 256, 0, 0, 0, 0, 0, false);
        CameraView->Blit(7, RT_CURRENT, 0, 0, 256, 256, 0, 0, 256, 256, 0, 0, 0, 0, 0, false);
    }
}

dmapdata script ExampleMap
{
    void run(int startRoom)
    {
        Z3ScrollingInit();

        int ExampleMapRooms[64] = {1, 3, 3,  3,  3,  3,  2, 0,
                                   1, 4, 4,  3,  5,  5,  2, 0,
                                   1, 4, 4,  3,  5,  5,  2, 0,
                                   1, 1, 1,  6,  2,  2,  2, 0,
                                   7, 9, 11, 11, 11, 10, 8, 0,
                                   7, 9, 11, 12, 11, 10, 8, 0,
                                   7, 9, 11, 11, 11, 10, 8, 0,
                                   7, 7, 7,  13, 8,  8,  8, 0};

        RoomInit(ExampleMapRooms, startRoom, 2);

        //Scrolling Logic Loop.
        while (true)
        {
            ScrollingEngineUpdate();
            Waitdraw();
            Waitframe();
        }
    }
}

Hero:

//Hero Sprite Tiles.
const int HERO_WALK_UP_SPRITE = 32000;
const int HERO_WALK_DOWN_SPRITE = 32009;
const int HERO_WALK_LEFT_SPRITE = 32020;
const int HERO_WALK_RIGHT_SPRITE = 32029;

//Hero Variables.
int HeroX = 0;
int HeroY = 0;
int WalkSpeed = 150;
const bool DEFUALT_ENGINE_HERO_ANIMATE_STATE = false;

void HeroInit()
{
    Hero->Animation = (DEFUALT_ENGINE_HERO_ANIMATE_STATE == true) ? true : false;
}

void HeroUpdate()
{
    int InputArray[4] = {Input->Button[CB_DOWN], Input->Button[CB_UP], Input->Button[CB_RIGHT], Input->Button[CB_LEFT]};
    int HorizontalInput = InputArray[2] - InputArray[3];
    int VerticalInput = InputArray[0] - InputArray[1];

    if (HorizontalInput != 0 || VerticalInput != 0)
    {
        HeroX += HorizontalInput * (WalkSpeed / 100);
        HeroY += VerticalInput * (WalkSpeed / 100);
    }
}

hero script HeroInit
{
    void run()
    {
        HeroInit();
    }
}

hero script HeroActive
{
    void run()
    {
        while (true)
        {
            HeroUpdate(); //Update our "real" hero object.
            NoAction(); //Kill Input from the hero to make sure they stay in place :).
            Waitframe(); //Wait until the next frame.
        }
    }
}

  • Bagu likes this

#2 Bagu

Bagu

    Fandomizer

  • Members
  • Real Name:A.I. Bot Bottomheimer
  • Location:Germany

Posted 01 October 2021 - 04:12 AM

Damned Great!!!



#3 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 02 October 2021 - 01:26 AM

I managed to create a proper camera so it follows the player, keep them in the center and keeps the camera in the boundary's of the room (if you want it that way, you can switch it off if needed): https://www.dropbox....Camera.mp4?dl=0


  • Bagu likes this

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 April 2022 - 12:18 PM

 

Anybody want too see some Z3 scrolling? (Its not complete but I manage to stitch it together to create something to show off, though very BARE bones): https://www.dropbox....-40-19.mp4?dl=0

 

 

 

 

https://github.com/Z...RPG/ScrollingZC

 

Take anything you want. It should be reasonably documented:
Tests:

https://github.com/Z.../Scrolltest.qst

https://github.com/Z...er/Mode7plus.zh

https://github.com/Z...l_13MAY2019.qst

 

IDK if I will ever find a desire to compete this.

https://github.com/Z...55Mode7Test.qst


Edited by Timelord, 28 April 2022 - 12:24 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users