/Mario-vs-Khabis-game

Mivehkhor(Fruit party) - related to a tutorial video

Primary LanguageLua

Mario vs Khabis

Mivehkhor or fruit party

preview

🍒🍓🍌🥝🥭🥕🍎🍏....💣

In this party you should eat fruit as much as you can
image
The winner is who has more scores
I made a video to explain how Lua works - in Persian
and this game is the result
Video is not ready yet.
only in 20min you can make a wonderful game
Try to get fruits(miveh) and avoid bombs.

🎮Play the game online

image

lexaloffle:
▶️Play online
Github:
▶️Play online

In Persian "khabis" means bad guy.
Khabis and mario try to get fruits and avoid bombs.
a simple senario and addictive game :)

Source Code

There are 3 main functions _init(),_update(),_draw()

function _init()
    music(1)
    game_over = false
    -- game config
    bc = 1
    chances= {10,30,50,90}-- in %percent
    bomb_chance= chances[bc]
end

function _update()
    mario.update()
    khabis.update(miveh)

    mario.collision(miveh)
    khabis.collision(miveh)

end

function _draw()
    cls()
    scores()
    khabis.draw()
    
    
    --bomb! or miveh(fruit)
    if bomb.active then
            bomb.draw()
    else
        miveh.draw()				
    end
    
    mario.draw()
end

Collision Detection

In physics, a collision is any event in which two or more bodies exert forces on each other in a relatively short time.

function collision(a,b,x,y)
    if (a <= x and a+8 >=x or 
            x <= a and x+8 >=a) and
                (b <= y and b+8 >=y or 
            y <= b and y+8 >=b) then
            return true
    end
        
    return false				
end

khabis_5

Simply move the mario with arrow keys

      if btn(⬅️) then
            mario.x-=speed
            mario.spr=4				
      end
      if btn(➡️) then
            mario.x+=speed	
            mario.spr=1			
      end

      if btn(⬆️) then
            mario.y-=speed				
      end
      if btn(⬇️) then
            mario.y+=speed				
      end

PICO-8 CheatSheet

CheatSheet

khabis

Watch the video for full tutorial
image

happy coding