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

as pixel explained it, it was my fault for not double checking the array tables... and the "function update(timeDelta)" that pixel provided for me greatly helped me to get the right timing for each frame! many thank to him! :D

alright, now that i fixed most of stuff, here the current code source i made so far:

-- still sprite of normal udder and clothed edition.
MomooStillN2={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}}
-- flick cycle of normal udder and clothed edition.
MomooFlickN2={width=8,unique=37,total=64,spriteIDs={-1,-1,-1,-1,0,1,2,-1,-1,-1,26,27,28,18,19,-1,-1,-1,65,66,101,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}}
-- idle cycle of normal udder and clothed edition.
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}}
-- speaking cycle of normal udder and clothed edition.
MomooSpeakingN2_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,102,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}}
MomooSpeakingN2_2={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,103,49,-1,-1,-1,-1,-1,112,120,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}}
MomooSpeakingN2_3={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,104,49,-1,-1,-1,-1,-1,112,120,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}}
MomooSpeakingN2_4={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,105,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}}
MomooSpeakingN2_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,106,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}}
MomooSpeakingN2_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,102,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}}
-- still sprite of normal udder and clothed edition.
local StillNormal2 = {
    {spriteData = MomooStillN2, time = 5}
}
-- Here we will store the random idle animation data.
-- the idle cycle of normal udder and clothed edition.
local idleNormal2Frames = {
    {spriteData = MomooIdleN2_1, time = .1},
    {spriteData = MomooIdleN2_2, time = .56},
    {spriteData = MomooIdleN2_3, time = .08},
    {spriteData = MomooIdleN2_4, time = .1},
    {spriteData = MomooIdleN2_5, time = .1},
    {spriteData = MomooIdleN2_6, time = .08}
}
-- flick cycle of normal udder and clothed edition.
local FlickNormal2 = {
    {spriteData = MomooFlickN2, time = .05}
}
-- The speaking cycle of normal udder and clothed edition.
local speakingNormal2Frames = {
    {spriteData = MomooSpeakingN2_1, time = .12},
    {spriteData = MomooSpeakingN2_2, time = .12},
    {spriteData = MomooSpeakingN2_3, time = .12},
    {spriteData = MomooSpeakingN2_4, time = .12},
    {spriteData = MomooSpeakingN2_5, time = .12},
    {spriteData = MomooSpeakingN2_6, time = .12}
}
-- these different local will be used for timing of each frame.
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);
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 each iddles animation features.
    idleTime = idleTime + timeDelta
    if(idleTime > idleDelay) then
        idleFrame = idleFrame + 1
        if(idleFrame > #idleNormal2Frames) then
             idleFrame = 1
        end
        idleDelay = idleNormal2Frames[idleFrame].time
        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()
    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)
    ]]
-- character position starter.
    local newX = 8
    local newY = 128
--that line of code will tell where to get the sprite data. so, the game will be able to animate them.
    local frameData = idleNormal2Frames[idleFrame]
-- that little "if(frameData ~= nil) then" is REALLY important to add. so, it will not display "out of the range"
-- everytime i start the game.
-- each variable will be called from the array code at the start of file.
    if(frameData ~= nil) then
        DrawSprites(frameData.spriteData.spriteIDs, newX, newY, frameData.spriteData.width)
    end
-- 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
end

of course, all the sprites data will be saved as "momoosprites.lua to avoid any change from "sb-sprites.lua" so, i could manually update each new data :) for now, all i'm trying to figure is how to randomize each idles, i suppose i have to use that math.random in one of these code line?

we will see how it will go with some test! :D

oh and i will soon post a demo example for those who want to know how to get a dynamic time frame for one animation.

edit: i forgot to fix that tiny bug in the

local framedData = idleNormal2Frames[idleFrame]

 XD;;;;