Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PAT Adventure N7
#1
Something is coming back !
Somewhere in the past, there was a game called PAT.
https://naalaa.com/forum/thread-10.html

But N7 version ....
   
Not exactly the same PAT.
Not exactly the same world.
And definitely not the same difficulty.
There may be a few surprising waiting for anyone who thinks they already know what's coming.

Will you be ready ?
Probably not.
But that's the fun part  Big Grin Big Grin Big Grin

More soon...
Reply
#2
The original PAT, written in N6 by JSM (John Master), has a lot of things to learn. To make it easier for me to understand the code and remake the game, I'm going to break the project into a series of smaller episodes.  The first episode is quite simple. It's mainly meant to give you a little practice with the basics - running, jumping, and collecting jewels...before things get more challenging in the episodes to come !

Use a joystick to control the player
 - LEFT, RIGHT
 - JUMP                = Joybutton(1)

Code:
'=============================================================================================
'
' PAT N7 (Training #1)
' Enter a dangerous world filled with bats, obstacles, mysterious paths, and precoius jewels !
' - Run & Jump          : Master your movement and navigate challenging stages.
' - Throw Rocks         : Take down bats before they take you down.
' - Use bombs           : Blast through obstacles and open new paths.
' - Collect every jewel : Explore every corner and collect them all.
' Can you survive the dangers, collect every jewel, and make it to the end ?
'
' Use a joystick to control the player
' - LEFT, RIGHT
' - JUMP                = Joybutton(1)
'
' Acknowledgment :
' - NES style platform game
'   N6 version by John Master
'
'==============================================================================================

#win32
include "tilemap.n7"

set window "PAT N7 (Training #1)", 256, 240, false, 2
set redraw off

visible sprite  = []
visible ply     = []        'Player
visible hud     = []        'Heads-Up-Display


'----------------
' Initialization
'----------------
hud.Stage   = 1
ply.ac      = 0 'animation count
LoadAssets()
Title()
LoadStage()


'------------
' Main Loop
'------------
while not keydown(KEY_ESCAPE,true)
    UpdatePlayer()
    DrawGame()

    ' Check for Level Complete
    if hud.Jewels = hud.JewelCount
        choice = ShowMenu("RESTART", "QUIT")
       
        if choice = 0
            ' RESTART
            hud.Stage = 1       
            LoadStage()         
        else
            ' QUIT
            end
        endif
    endif

    redraw
    fwait 60
wend


'-----------
' Functions
'-----------
function LoadAssets()
    sprite.Font     = loadfont("assets1/font8"); set font sprite.Font
    sprite.Title1   = loadimage("assets1/title1.png")
    sprite.Title2   = loadimage("assets1/title2.png")
    sprite.Player   = loadimage("assets1/player.png", 6, 3)
endfunc

function Title()
     set color 5,7,31;cls; set color 255,255,255

    'Title 1
    draw image sprite.Title1, 5, 0
    redraw; delay(1)
   
    'Title 2
    draw image sprite.Title2, 0, 0
    redraw ; delay(1)
endfunc

'delay t seconds
function delay(t)
    t_start = clock()
    while clock() - t_start < (t*1000)
        fwait 16
    wend
endfunc

function LoadStage()
    ply.img = sprite.Player             'Used to check if player is alive/loaded
    ply.w = width(sprite.Player)        'Used in camera calculation
    ply.h = height(sprite.Player)       'Used in Collision checks
    ply.dx = 0 ; ply.dy = 0
    ply.bf = 0                          'Base frame direction (0=right, 6=left).
    ply.f = 0                           'animation frame index.
    ply.c = 0                           'Current cel index drawn on screen.
    ply.gr = -1                         'Ground state flag. Jump logic checks ply.gr >= 0
   
    hud.JewelCount = 0
    hud.Jewels = 0

    'Load Tilemap
    TM_LoadMap("assets/t" + (hud.Stage) + ".txt")
   
    'Tilemap : Get Loader flags
    flags = TM_GetLoaderFlags()
    foreach f in flags
        if f.flag = 1 'player
            ply.x = (f.x * 16)
            ply.y = (f.y * 16 + 16 - ply.h)
        endif
    next

    'Tilemap : Get Cell
    for y = 0 to TM_MapHeight() - 1
        for x = 0 to TM_MapWidth() - 1
            c = TM_GetCel(x, y)
            if c = 42 'jewel
                hud.JewelCount = hud.JewelCount + 1
            endif
        next
    next

    'Tilemap : Set View
    TM_SetView(0, 0, width(primary), height(primary))
endfunc

function UpdatePlayer()
    'Player animation counter
    ply.ac = ply.ac + 1
   
    if ply.ac >= 10 then
        ply.ac = 0
        ply.f = (ply.f + 1) % 4
    endif

    ply.dy = min(ply.dy + 0.2, 4.0)

    'Player movement
    jx = joyx()
    moveRight = jx > 0.5
    moveLeft = jx < -0.5

    if moveRight or keydown(KEY_RIGHT)
        ply.dx = min(ply.dx + 0.5, 2.0)
        ply.bf = 0
        ply.c = ply.bf + 1 + ply.f
    elseif moveLeft or keydown(KEY_LEFT)
        ply.dx = max(ply.dx - 0.5, -2.0)
        ply.bf = 6
        ply.c = ply.bf + 1 + ply.f
    else
        ply.f = 0
        ply.c = ply.bf
        if ply.dx > 0.0 then
            ply.dx = max(ply.dx - 0.25, 0.0)
        endif
        if ply.dx < 0.0 then
            ply.dx = min(ply.dx + 0.25, 0.0)
        endif
    endif

    'Jump
    if (joybutton(1, true) or keydown(KEY_SPACE,true)) and ply.gr >= 0
        ply.dy = -4.5
        ply.gr = -1
    endif

    ' Jump animation frame
    if ply.dy < 0.0
        if ply.bf = 0 then
            ply.c = 4
        elseif ply.bf = 6 then
            ply.c = 10
        endif
    endif

    ' Tilemap : Move Sprite, CollisionDown, CollisionUp
    TM_MoveSprite(ply, ply.dx, ply.dy)

    if TM_CollisionDown()
        leftCel = TM_GetCel(TM_ToMapX((ply.x)), TM_ToMapY((ply.y) + ply.h + 8))
        rightCel = TM_GetCel(TM_ToMapX((ply.x) + 15), TM_ToMapY((ply.y) + ply.h + 8))
       
        if (leftCel = 12 and rightCel = 20) or (leftCel = 20 and rightCel = 12)
            ply.gr = 0
        elseif leftCel = 12 or rightCel = 12
            ply.gr = 12
        elseif leftCel = 20 or rightCel = 20
            ply.gr = 20
        else
            ply.gr = 0
        endif
    endif

    if TM_CollisionUp() then
        ply.dy = 0.0
    endif

    'Tilemap : pickup
    pX = TM_ToMapX((ply.x) + ply.w/2)
    pY = TM_ToMapY((ply.y) + ply.h/2)
    c = TM_GetCel(pX, pY)

    if c = 42
        TM_SetCel(pX,pY,-1)
        hud.Jewels = hud.Jewels + 1
        hud.Score = hud.Score + 50
    endif

    'Tilemap : Set Camera
    camX = ply.x + ply.w/2 - width(primary)/2
    camY = ply.y + ply.h/2 - height(primary)/2
    TM_SetCamera(camX, camY)
endfunc

function DrawGame()
    set color 0, 0, 0; cls; set color 255, 255, 255
   
    'Tilemap : Render
    TM_Render()
   
    draw image ply.img, TM_ToScreenX((ply.x)), TM_ToScreenY((ply.y)), ply.c
endfunc

function ShowMenu(opt1, opt2)
    cursor = 0
    do
        ' Menu Box
        set color 100, 100, 100, 100
        draw rect 20, 10, 120, 40, true

        ' Option 1 (Restart)
        set color 255, 255, 255
        if cursor = 0 then set color 255, 255, 0
        set caret 50, 20
        wln opt1

        ' Option 2 (Quit)
        set color 255, 255, 255
        if cursor = 1 then set color 255, 255, 0
        set caret 50, 30
        wln opt2

        redraw
        fwait 60

        ' Input Navigation
        if joyy() < -0.5 or keydown(KEY_UP,true) then cursor = 0
        if joyy() > 0.5 or keydown(KEY_DOWN,true) then cursor = 1
        if joybutton(1) or keydown(KEY_SPACE,true) then return cursor
        if keydown(KEY_ESCAPE, true) then return 1
    loop
endfunc


Attached Files
.zip   Training_1.zip (Size: 122.68 KB / Downloads: 6)
Reply
#3
Just download and executed....

Got the follow message...

   
Logic is the beginning of wisdom.

Live long and prosper.
Reply
#4
I wonder if "Pat" is a reference to the youtuber "Pat the NES Punk" (Pat Conti)?
Reply
#5
(09-23-2026, 07:42 AM)johnno56 Wrote: Just download and executed....

Got the follow message...

Looks like you've hit a little bug there  Big Grin
The fix should be pretty simple, just go to the LoadStage() function and change :

TM_LoadMap("assets/t" ...)

to

TM_LoadMap("assets1/t" ...)

That should hopefully do the trick.

(09-23-2026, 09:11 AM)Marcus Wrote: I wonder if "Pat" is a reference to the youtuber "Pat the NES Punk" (Pat Conti)?

Probably just a coincidence ... maybe  Big Grin Big Grin Big Grin
Reply
#6
Cool... That worked!

Are you planing on an N7 conversion of Pat or something based on the game?
Logic is the beginning of wisdom.

Live long and prosper.
Reply
#7
(09-23-2026, 09:29 AM)johnno56 Wrote: Cool... That worked!

Are you planing on an N7 conversion of Pat or something based on the game?

A full conversion isn't what I'm planning. For now, something based on the original version's game logic seems more likely, with PAT sprites being the more probable direction.
More updates will be coming as I continue getting and understanding the N6 version.

               

Later, when the time comes, would you be willing to help me create some more complex tilemap stages, like the ones you've shown in the Space Pooper game ? I'd really appreciate your help. Thank you in advance !

Cool
Reply
#8
It's been quite a while since I have tackled the tile map editor. I have always found it relatively easy to "draw" the map... when it comes to coding.... not so easy... lol That being said, if help is what you need... then help is what you will get... Wink
Logic is the beginning of wisdom.

Live long and prosper.
Reply
#9
(09-23-2026, 11:34 AM)johnno56 Wrote: It's been quite a while since I have tackled the tile map editor. I have always found it relatively easy to "draw" the map... when it comes to coding.... not so easy... lol  That being said, if help is what you need... then help is what you will get... Wink

some inspiration :

               
Reply
#10
Ah. Now these look familiar... The last time I played those levels I think it took me several lives to get through them.... the memories...

Come to think of it... I can only remember the first three levels... was there a forth?
Logic is the beginning of wisdom.

Live long and prosper.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)