🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles
(Edited 2 times)

alright! now that the PV8 update is finally here, the new features are wonderful but that doesn't solve the problem i have.


here how it will happen when i use the current code as result:


as you can see, it's not what i'm trying to achieve, here what is the goal i wanted the game display:

as you can see, the duration of each frame are dynamic which it's exactly what i'm trying to achieve. do you know what is the right methode to achieve it?

i will upload the code source once i finish cleaning them all from the old api to the new api.

alright, i just finished cleaning my code source and added the mouse features that worked pretty well but not yet fixed the sprite part of character... i always get that message: 

"IndexOutOfRangeException:
Array index is out of range."

wondering why it happened even though i did them right... might have something about the last part of code. allright, here the code source:

-- spritelib-start
-- idle cycle of normal udder and clothed edition.
MomooIdleN2_1={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,0,1,2,-1,-1,-1,15,16,17,18,19,-1,-1,-1,45,46,91,92,49,-1,-1,-1,-1,-1,112,113,114,-1,-1,158,159,160,161,224,225,-1,-1,235,236,237,238,321,322,323,-1,-1,-1,348,349,428,429,430,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_2={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,3,4,5,-1,-1,-1,20,21,22,23,24,-1,-1,-1,50,51,93,94,54,-1,-1,-1,-1,-1,115,116,117,-1,-1,158,159,164,226,227,228,-1,-1,235,236,242,243,324,325,326,-1,-1,-1,270,353,431,429,432,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_3={width=8,unique=36,total=64,spriteIDs={-1,-1,-1,-1,3,4,5,-1,-1,-1,20,21,22,25,24,-1,-1,-1,50,51,95,96,57,-1,-1,-1,-1,-1,118,119,117,-1,-1,167,168,169,229,227,230,-1,-1,245,246,247,248,327,328,329,-1,-1,-1,355,356,433,434,-1,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_4={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,3,4,5,-1,-1,-1,20,21,22,23,24,-1,-1,-1,50,51,93,97,59,-1,-1,-1,-1,-1,115,116,117,-1,-1,158,159,164,226,227,228,-1,-1,235,236,242,243,324,325,326,-1,-1,-1,270,353,431,429,432,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_5={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,0,1,2,-1,-1,-1,15,16,17,18,19,-1,-1,-1,45,46,91,98,61,-1,-1,-1,-1,-1,112,120,121,-1,-1,158,159,160,161,224,225,-1,-1,235,236,237,238,321,322,323,-1,-1,-1,348,349,428,429,430,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_6={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,0,1,2,-1,-1,-1,15,16,17,18,19,-1,-1,-1,45,46,91,99,63,-1,-1,-1,-1,-1,112,113,114,-1,-1,158,159,160,161,224,225,-1,-1,235,236,237,238,321,322,323,-1,-1,-1,348,349,428,429,430,-1,-1,-1,-1,452,489,490,-1}}
MomooIdleN2_7={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,0,1,2,-1,-1,-1,15,16,17,18,19,-1,-1,-1,45,46,91,100,49,-1,-1,-1,-1,-1,112,113,114,-1,-1,158,159,160,161,224,225,-1,-1,235,236,237,238,321,322,323,-1,-1,-1,348,349,428,429,430,-1,-1,-1,-1,452,489,490,-1}}
-- spritelib-end
-- mode enums
local Up, Down, Right, Left, A, B, Select, Start = 0, 1, 2, 3, 4, 5, 6, 7
    local MomooIdleNormal2Sprites = {
            MomooIdleN2_1[1],
            MomooIdleN2_2[1],
            MomooIdleN2_3[1],
            MomooIdleN2_4[1],
            MomooIdleN2_5[1],
            MomooIdleN2_6[1],
            MomooIdleN2_7[1],
            MomooIdleN2_8[1]}
local idleNormal2Animation = {
    {sprite = MomooIdleNormal2Sprites[1], hFlip = false, vFlip = false, time = 2},
    {sprite = MomooIdleNormal2Sprites[2], hFlip = false, vFlip = false, time = .1},
    {sprite = MomooIdleNormal2Sprites[3], hFlip = false, vFlip = false, time = .16},
    {sprite = MomooIdleNormal2Sprites[4], hFlip = false, vFlip = false, time = .4},
    {sprite = MomooIdleNormal2Sprites[5], hFlip = false, vFlip = false, time = .08},
    {sprite = MomooIdleNormal2Sprites[6], hFlip = false, vFlip = false, time = .1},
    {sprite = MomooIdleNormal2Sprites[7], hFlip = false, vFlip = false, time = .1},
    {sprite = MomooIdleNormal2Sprites[8], hFlip = false, vFlip = false, time = .08}
}
-- Here we will store the random idle animation data
local idleDelay = .2
local idleTime = 0
local idleFrame = 1
-- The Mouse Demo shows off how to capture mouse input and display a cursor on the screen.
-- Pixel Vision 8 requires the runner to supply mouse data via the ControllerChip.You will
-- need to implement the IMouseInput interface and register a custom Mouse Class with the
-- ControllerChip in order for this demo to work.
-- We need to create some fields to store the mouse cursor's sprites, dimensions, position, and offset.
local greenCursorSprites = {0493,0494,0495,0496}
local redCursorSprites = {0497,0498,0499,0500}
local greyCursorSprites = {0501,0502,0503,0504}
local handCursorSprites = {0505,0506,0507,0508}
local eyeCursorSprites ={0509,0510,0511,0512}
local crossCursorSprites ={0513,0514,0515,0516}
local cursorWidth = 2
local fontOffsetX = 128
local mousePos = {x = -1, y = 0}
-- The Init() method is part of the game's lifecycle and called a game starts. We are going to
-- use this method to configure background color, ScreenBufferChip and draw a text box.
function Init()
    -- Before we start, we need to set a background color and rebuild the ScreenBufferChip. The screen buffer
    -- allows us to draw our fonts into the background layer to save on draw calls.
    BackgroundColor(31)
    DrawText("momoo game test Demo", 1, 1, DrawMode.Tile, "default")
    -- This default text will help display the current state of the mouse. We'll render it into the
    -- ScreenBufferChip to cut down on sprite draw calls.
    DrawText("MOUSE POSITION", 1, 1, DrawMode.Tile, "large-font", 0);
    DrawText("BUTTON 1 DOWN", 1, 3, DrawMode.Tile, "large-font", 0);
    DrawText("BUTTON 2 DOWN", 1, 4, DrawMode.Tile, "large-font", 0);
    local pipeX = 1
    local pipeY = 21
end
-- The Update() method is part of the game's life cycle. The engine calls Update() on every frame
-- before the Draw() method. It accepts one argument, timeDelta, which is the difference in
-- milliseconds since the last frame.
function Update(timeDelta)
    -- The APIBridge exposes a property for the mouse's x and y position. We'll store this in a field and
    -- retrieve it during Draw() execution of the GameChip's life cycle.
    mousePos = MousePosition()
    -- While this step may appear to be wasteful, it's important to separate any calculation logic from
    -- render logic. This optimization technique will ensure the best performance for Pixel Vision 8 games
    -- and free up the Draw() method to only focus on rendering.
    -- Here we are tracking the fireball animation
    idleTime = idleTime + timeDelta
    if(idleTime > idleDelay) then
        idleFrame = idleFrame + 1
        if(idleFrame > #idleNormal2Animation) then
             idleFrame = 1
        end
        idleTime = 0
        end
    end
-- The Draw() method is part of the game's life cycle. It is called after Update() and is where
-- all of our draw calls should go. We'll be using this to render sprites to the display.
function Draw()
    -- We can use the DrawScreenBuffer() method to clear the screen and redraw the tilemap in a
    -- single call.
    Clear()
    DrawTilemap(0, 0, 32, 30)
    -- We can use the RedrawDisplay() method to clear the screen and redraw the tilemap in a
    -- single call.
    RedrawDisplay()
    -- For the last bit of code we are just going to display whether the left or right mouse button is being held down by using the
    -- GetMouseButton() method on the APIBridge.
    DrawText(tostring(MouseButton(0)):upper(), fontOffsetX - 8, 24, DrawMode.Sprite, "large-font", 0)
    DrawText(tostring(MouseButton(1)):upper(), fontOffsetX - 8, 32, DrawMode.Sprite, "large-font", 0)
    -- We are going to detect if the mouse is on the screen. When the cursor is within the bounds
    -- of the DisplayChip, we will show its x and y position.
    if (mousePos.x < 0 or mousePos.y < 0) then
        DrawText("OFFSCREEN", fontOffsetX, 8, DrawMode.Sprite, "large-font", 0)
    else
        -- Pixel Vision 8 automatically returns a -1 value for the mouse x and y position if it is out of the bounds of the DisplayChip
        -- or if a mouse was is not registered with the ControllerChip.
        -- Since the mouse within the display, let's show its current x and y position.
        DrawText("(" ..  mousePos.x .. "," .. mousePos.y .. ")", fontOffsetX, 8, DrawMode.Sprite, "large-font", 0)
        -- We also need to draw it to the display. We'll be using the DrawSprites() method to take the four cursor sprites and render them in a 2 x 2 grid.
        DrawSprites(greenCursorSprites, mousePos.x, mousePos.y, cursorWidth)
    end
    local newX = 8
    local newY = 48
    local frameData = idleNormal2Animation[idleFrame]
    newX = newX + 16
    DrawSprite(frameData.sprite, newX, newY, frameData.hFlip, frameData.vFlip) --frameData.time)
end

to be honest, this new api is really more elegant and cleaner than the old version which i'm very happy of the result! :) too bad that last portion of code is bugging me for a while now XD;