🤑 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.
-- flick cycle of normal udder and clothed edition.
-- idle cycle of normal udder and clothed edition.
-- speaking cycle of normal udder and clothed edition.
-- 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.
    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);
-- 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
        idleDelay = idleNormal2Frames[idleFrame].time
        idleTime = 0
-- 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()
-- 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)
-- 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)
-- 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)

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]