old attempt at writing a platform game

Game development specific discussions.
BasicCoder2
Posts: 3298
Joined: Jan 01, 2009 7:03

old attempt at writing a platform game

Postby BasicCoder2 » Feb 25, 2018 7:47

Three years ago back in 2015 I last fooled around with the idea of writing a retro platform game. Wrote tile and sprite editors to help. The problem is always the talent needed to draw the graphics and create any musical background!! Sound effects are easy enough although FreeBASIC has no innate support for them. It also seemed to me that duplicating an existing game would at least show that you could do it. At the time someone was toying with the idea of a Wonder Boy clone so I thought might do the same and used the ripped Wonder Boy graphics. However I couldn't post the code because they were not my graphics.
After reading the posts from badidea and coderJeff I thought I might post my first attempt. I thought maybe I could replace the graphics with quickly drawn PAINT images to replace the original sprite images. They don't look as good. It is amazing what good graphics can do to enhance a game's appearance although game play is a separate issue.
Download this image and resave as spriteBlock.bmp
Image
The few tiles used are are generated in the program code.
Arrow keys left/right. Jump with Up arrow key. Control key punches arm. Punch botton on right wall will exit program. Punch enemy to stop it. The yellow floor tile was a take on Wonder boys trampoline tile.

Code: Select all

screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255)
cls

'GLOBAL VARIABLES
dim shared as integer GameOver  'flag a game end event has occurred
dim shared as integer hitGround,hitRoof,hitRightWall,hitLeftWall
dim shared as integer mx,my,mb   'mouse variables
dim shared as double now1
now1 = timer
dim shared as integer jumpCounter  'count how long up key pressed
dim shared as integer state        'state of hero

dim shared as integer WINW,WINH,WINX,WINY  'DISPLAY window of bitmap
WINX = 0
WINY = 0
WINW = 640   
WINH = 380

const MAPW = 60   ' size in tiles
const MAPH = 20   '
const TILEW = 32  ' size in pixels
const TILEH = 32

dim shared as integer BMAPW = MAPW*TILEW
dim shared as integer BMAPH = MAPH*TILEH

dim shared as any ptr LAYER0         'background
LAYER0 = imagecreate(BMAPW,BMAPH)

dim shared as any ptr LAYER1         'areas behind sprites
LAYER1 = imagecreate(BMAPW,BMAPH)

dim shared as any ptr LAYER2        'areas that contact sprites
LAYER2 = imagecreate(BMAPW,BMAPH)

dim shared as any ptr LAYER3        'areas in front of sprites
LAYER3 = imagecreate(BMAPW,BMAPH)

dim shared as any ptr DISPLAY
DISPLAY = imagecreate(BMAPW,BMAPH) 'holds combination of layers for display

dim shared as integer tileID(MAPW,MAPH)       'holds tile ID's

'=========  LOAD TILE BLOCK BITMAP =========
dim as any ptr tileBlock
tileBlock = imagecreate(TILEW*16,TILEH*16,rgb(255,0,255))
'bload "tileBlock.bmp",tileBlock
'== create tiles used ===

line tileBlock,(32,0)-step(31,31),rgb(200,100,200),bf  'background tiles
line tileBlock,(32,0)-step(31,31),rgb(0,0,0),b


line tileBlock,(256,0)-step(31,31),rgb(100,100,20),bf 'tile with button
line tileBlock,(256,0)-step(31,31),rgb(0,0,0),b
circle tileBlock,(272,16),10,rgb(195,195,195),,,,f  'draw gray button

line tileBlock,(0,128)-step(31,31),rgb(0,162,232),bf  'sky


line tileBlock,(32,128)-step(31,31),rgb(0,128,0),bf 'wall tiles
line tileBlock,(32,128)-step(31,31),rgb(0,0,0),b

line tileBlock,(32,160)-step(31,31),rgb(200,200,0),bf
line tileBLock,(32,160)-step(31,31),rgb(0,0,0),b           'trampoline tile


'=========  LOAD BITMAP BLOCK OF SPRITES ====
dim shared as any ptr spriteBlock
spriteBlock = imagecreate(300,182)
bload "spriteBlock.bmp",spriteBlock

'read tile data
dim as integer xx,yy,ID
for i as integer = 0 to MAPW-1
    for j as integer = 0 to  MAPH-1
        read tileID(i,j)
        ID = tileID(i,j)
        'get xx,yy coordinate of tile ID in spriteBlock
        yy = int(ID/16)
        xx = ID - (yy*16)
        'copy tile image into layer
        if ID>64 then
            put LAYER2,(i*TILEW,j*TILEH),tileBlock,(xx*TILEW,yy*TILEH)-(xx*TILEW+TILEW-1,yy*TILEH+TILEH-1),pset
        else
            put LAYER1,(i*TILEW,j*TILEH),tileBlock,(xx*TILEW,yy*TILEH)-(xx*TILEW+TILEW-1,yy*TILEH+TILEH-1),pset
        end if
    next j
next i

' ================== create a sprite ========
type SPRITE
    as integer x
    as integer y
    as integer w
    as integer h
    as double dx     'left = -dx, right = +dx not moving = 0
    as double dy     'up/down
    as integer f     'frame number for animated sprites images
    as integer c     'timer counter for animation
    as integer d     'last direction along x axis
    as integer alive 'alive?
end type

'create sprite
dim shared as SPRITE hero
dim shared as SPRITE mole
dim shared as integer heroHitMole

' ----------- initialize sprite data --------------
hero.w = 47
hero.h = 59
hero.x = 500
hero.y = 609-hero.h
hero.dx = 0
hero.dy = 4      'gravity
hero.alive = 1

mole.w = 32
mole.h = 32
mole.x = 140
mole.y = 609-mole.h
mole.dx = 1
mole.dy = 0
mole.alive = 1


'---------------------------------------------------
function testCollision(b1 as SPRITE,b2 as SPRITE) as boolean
    return b2.y < (b1.y + b1.h) and (b2.y + b2.h) > b1.y and b2.x < (b1.x + b1.w) and (b2.x + b2.w) > b1.x
end function

function spriteCollision(s1 as SPRITE,s2 as SPRITE) as integer
    dim as integer hit
    hit = 0
    'top/left corner
    if s1.x >= s2.x and s1.x <= (s2.x+s2.w) then
        if s1.y >= s2.y and s1.y <= (s2.y+s2.h) then
            hit = hit or 1
        end if
    end if
    'top/right corner
    if s1.x+s1.w >= s2.x and s1.x+s1.w <= (s2.x+s2.w) then
        if s1.y >= s2.y and s1.y <= (s2.y+s2.h) then
            hit = hit or 2
        end if
    end if
    'bottom/left corner
    if s1.x >= s2.x and s1.x <= (s2.x+s2.w) then
        if s1.y+s1.h >= s2.y and s1.y+s1.h <= (s2.y+s2.h) then
            hit = hit or 4
        end if
    end if
    'bottom/right corner
    if s1.x+s1.w >= s2.x and s1.x+s1.w <= (s2.x+s2.w) then
        if s1.y+s1.h >= s2.y and s1.y+s1.h <= (s2.y+s2.h) then
            hit = hit or 8
        end if
    end if
    return hit
end function

sub updateData()
       
       
        if hitGround = 1 then
            jumpCounter = 0
        else       
            'air friction
            if hero.dx > 0 then
                hero.dx = hero.dx - .1
            end if
            if hero.dx < 0 then
                hero.dx = hero.dx + .1
            end if
        end if

        '==========

      '  if hitGround = 1 then
            hero.dx = 0  'can only move when on ground and left/right key down
            'MOVE RIGHT
            if multikey(&H4D) then
                hero.dx = 4
                hero.d  = 1
            end if       
            'MOVE LEFT
            if multikey(&H4B) then
                hero.dx =  -4
                hero.d  =  -1
            end if
       ' end if
       
       
        'JUMP UP
        if multikey(&H48) then
            if hitGround = 1 then
                hitGround = 0
                hero.dy  = -8      'updward velocity
                jumpCounter = 12   'start time in air counter
            else  'in the air
                if jumpCounter > 0 then
                    jumpCounter = jumpCounter - 1
                    hero.dy = -8
                end if
            end if
        end if

        if hero.f > 3 then hero.f = 0
       
        if multikey(&H1D) then    'control key
            hero.f = 4            'draw sword sprite
        end if
       
        ' CHARACTER DUCKS DOWN OR JUMPS DOWN THROUGH PLATFORM
        ' if multikey(&H1F) or multikey(&H50) then 
        ' end if
       
        'update position and test for out of bounds
        hero.x = hero.x + hero.dx
        if hero.x < 0 then hero.x = 0
        if hero.x > BMAPW-hero.w then
            hero.x = bMAPW-hero.w
        end if
       
        hero.y = hero.y + hero.dy    'moves down
        if hero.dy < 4 then
           hero.dy = 4               'constant velocity no acceleration or friction
        end if
   
        if hero.y < 0 then hero.y = 0
        if hero.y > BMAPH-hero.h then
            hero.y = bMAPH-hero.h
        end if       
        if hero.y<0 then hero.y = 0
        if hero.y>BMAPH-hero.h then
            hero.y = BMAPH-hero.h
        end if
   
        'scroll screen if required
        WINX = hero.x - (WINW\2)
        if WINX < 0 then WINX = 0
        if WINX > (BMAPW - WINW) then WINX = (BMAPW - WINW)
        WINY = hero.y - (WINH\2)
        if WINY < 0 then WINY = 0
        if WINY > (BMAPH - WINH) then WINY = (BMAPH - WINH)

        'update sprite frame
        if hero.dx <> 0 then 'must be running
            if hero.c < 5 then
                hero.c = hero.c + 1
            else
                hero.c = 0
                hero.f = hero.f + 1
                if hero.f > 3 then
                    hero.f = 0
                end if
            end if
        end if
       
    'test for sprite collision
    if  mole.alive = 1 then
        if  spriteCollision(mole,hero)<>0 then
            if hero.f = 4 then  'hero striking out
                mole.alive = 0
               mole.f = 2            'dead mole
           else
               hero.f = 5            'struck hero
               'toss hero

           end if
        end if
    end if
   
   
    if mole.alive = 1 then
        'update frame
        mole.c = mole.c + 1
        if mole.c = 25 then
            mole.c = 0
            mole.f = mole.f + 1
            if mole.f > 1 then
                mole.f = 0
            end if
        end if
   
        'reverse direction if hit wall
        mole.x = mole.x + mole.dx
        if mole.x<32 or mole.x >= BMAPW - 64 then
            mole.dx = -mole.dx
        end if
       
    end if

'=====================
       
    dim as integer px1,px2
    px1 = hero.w\3:px2 = px1*2  'two between top and bottom
   
    hitRoof = 0
    hitGround = 0

    'test for contact with roof
    if point(hero.x+px1,hero.y,LAYER2)<>rgb(255,0,255) or point(hero.x+px2,hero.y,LAYER2)<>rgb(255,0,255) then
        hitRoof = 1
        'move down until no longer hits roof
        while point(hero.x+px1,hero.y,LAYER2)<>rgb(255,0,255) or point(hero.x+px2,hero.y,LAYER2)<>rgb(255,0,255)
            hero.y = hero.y + 1
        wend
        'GET TILE NUMBER
    end if

    'test for contact with ground
    if point(hero.x+px1,hero.y+hero.h-1,LAYER2)<>rgb(255,0,255) or point(hero.x+px2,hero.y+hero.h-1,LAYER2)<>rgb(255,0,255) then
        hitGround = 1
        'move up until no longer hits ground
        while point(hero.x+px1,hero.y+hero.h-1,LAYER2)<>rgb(255,0,255) or point(hero.x+px2,hero.y+hero.h-1,LAYER2)<>rgb(255,0,255)
            hero.y = hero.y - 1
        wend
        'GET TILE NUMBER
    end if

    dim as integer py1,py2
    py1 = hero.h\3:py2 = py1*2  'two between top and bottom
   
    'test for contact with right wall
    if point(hero.x+hero.w-1,hero.y+py1,LAYER2)<>rgb(255,0,255) or point(hero.x+hero.w-1,hero.y+py2,LAYER2)<>rgb(255,0,255) then
        hitRightWall = 1
        'move left until no longer hits right wall
        while  point(hero.x+hero.w-1,hero.y+py1,LAYER2)<>rgb(255,0,255) or point(hero.x+hero.w-1,hero.y+py2,LAYER2)<>rgb(255,0,255)
            hero.x = hero.x - 1
        wend
        'GET TILE NUMBER
    end if
   
    'test for contact with left wall
    if point(hero.x,hero.y+py1,LAYER2)<>rgb(255,0,255) or point(hero.x,hero.y+py2,LAYER2)<>rgb(255,0,255) then
        hitLeftWall = 1
        'move right until no longer hits left wall
        while  point(hero.x,hero.y+py1,LAYER2)<>rgb(255,0,255) or point(hero.x,hero.y+py2,LAYER2)<>rgb(255,0,255)
            hero.x = hero.x + 1
        wend
        'GET TILE NUMBER
    end if

    'on trampoline
    if tileID(hero.x\tileW+0,hero.y\tileH+2)=81 or tileID(hero.x\tileW+1,hero.y\tileH+2)=81 then
        if hitGround = 1 then
            hitGround = 0
            hero.dy  = -88      'updward velocity
            jumpCounter = 212   'start time in air counter
        end if
    end if
           
end sub


sub updateDisplay()
    'put DISPLAY,(0,0),LAYER0,pset   'sky and clouds
    put DISPLAY,(0,0),LAYER1,trans  'areas behind sprites
    put DISPLAY,(0,0),LAYER2,trans  'areas that interact with sprite
    'put DISPLAY,(0,0),LAYER3,trans  'areas in front of sprite
   
    'draw mole sprite
    if mole.f < 2 then
        if mole.dx = 1 then  'moving left or right
            put DISPLAY,(mole.x,mole.y),spriteBlock,(mole.f*mole.w,150)-(mole.f*mole.w+mole.w-1,150+31),trans
        else
            put DISPLAY,(mole.x,mole.y),spriteBlock,(mole.f*mole.w,119)-(mole.f*mole.w+mole.w-1,119+31),trans
        end if
    end if
   
    if mole.f = 2 then
        put DISPLAY,(mole.x,mole.y),spriteBlock,(64,119)-(64+31,119+31),trans
    end if
   
    'draw character sprite
   
    if hero.f < 4 then
        if hero.d = 1 then  'moving left or right
            put DISPLAY,(hero.x,hero.y),spriteBlock,(hero.f*hero.w,59)-(hero.f*hero.w+hero.w-1,59+58),trans
        else
            put DISPLAY,(hero.x,hero.y),spriteBlock,(hero.f*hero.w,0)-(hero.f*hero.w+hero.w-1,57),trans
        end if
    end if
   
    if hero.f = 4 then  'hero striking out
        if hero.d = 1 then  'moving left or right
            put DISPLAY,(hero.x,hero.y),spriteBlock,(188,0)-(188+63,57),trans           
        else
            put DISPLAY,(hero.x-14,hero.y),spriteBlock,(188,59)-(188+63,59+58),trans
        end if
    end if
   
    if hero.f = 5 then  'hit by enemy
        put DISPLAY,(hero.x,hero.y),spriteBlock,(254,0)-(254+47,59),trans
    end if
   
    put DISPLAY,(0,0),LAYER3,trans   'areas in front of sprites
   
    'show visible part of DISPLAY image   
    screenlock()
    put (0,0),DISPLAY,(WINX,WINY)-(WINX+WINW-1,WINY+WINH-1),pset  'show visible part
   
    locate 2,2
    print tileID(hero.x\tileW+2,hero.y\tileH);"   ";
    print tileID(hero.x\tileW+2,hero.y\tileH+1)
   
    'did hero press tile with exit key?
    if hero.f = 4 and tileID(hero.x\tileW+2,hero.y\tileH)=8 then
        gameOver = 1
    end if
    screenunlock()
   
end sub
updateDisplay()
do
   
    if timer > now1 + 0.00001 then
        now1 = timer
        updateData()
        updateDisplay()
    end if
    sleep 2
loop until multikey(&H01) or gameOver = 1 'esc key or hero enters castle


imagedestroy(DISPLAY)
imagedestroy(LAYER3)
imagedestroy(LAYER2)
imagedestroy(LAYER1)
imagedestroy(LAYER0)

'tile array
DATA  64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,8,65,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,81
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,1,1,1,1,65
DATA  64,64,64,64,64,64,64,64,65,65,65,65,65,65,65,65,65,8,65,65
Last edited by BasicCoder2 on Feb 25, 2018 22:52, edited 1 time in total.
badidea
Posts: 964
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: old attempt at writing a platform game

Postby badidea » Feb 25, 2018 18:34

Looks cool.

The whole game goes a bit fast here. Walk from left to right wall takes approximately 3 seconds.

The trampoline gives some weird physics. With some air jumping, I can reach the top of the right wall:

Image
BasicCoder2
Posts: 3298
Joined: Jan 01, 2009 7:03

Re: old attempt at writing a platform game

Postby BasicCoder2 » Feb 25, 2018 20:01

Looks better with the original graphics. It is of course not a game just a first attempt at writing one.
The whole game goes a bit fast here. Walk from left to right wall takes approximately 3 seconds.

There appears to be something serious amiss in how I am setting the timing of the game cycles?

Code: Select all

if timer > now1 + 0.00001 then

Using say 0.001 doesn't seem to have an change.
If i change it to,

Code: Select all

if timer > now1 + 0.01 then

it still cycles at the same speed.
Any larger number such as 0.1 will slow it right down.
I am using a Window 10, Intel(R)Core(TM)i5-7200U CPU @2.50GHz 64bit OS
The trampoline gives some weird physics. With some air jumping, I can reach the top of the right wall:

The code is a bit messy and was written within a day after which I kind of lost interest as FreeBASIC was no longer being actively used for writing these retro games anymore so I would have to clean it up and try and follow the logic of the code again after not seeing it for three years. I just posted after reading your post and the post of coderJeff. Probably a bad thing to post less than complete code but it was that or not post at all.
There is a video on game video physics at the link below. Jumps physics is designed for game play not reality.
https://www.kotaku.com.au/2016/03/the-m ... d-jumping/

It all comes back to the fact that, just as knowing how to read and write doesn't mean you can write a novel, knowing how to program doesn't mean you can write a game that will capture other people's interest to play it.
badidea
Posts: 964
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: old attempt at writing a platform game

Postby badidea » Feb 25, 2018 21:30

Edit: My linux system does not do a 'screensync', a windows system maybe does. If I add a 'screensync' command, It goes significantly slower, maybe too slow now. 10 seconds from one side to the other.

Instead of trying to control the loop speed, you can also accept that it is difficult to control and use the loop time difference in the control.
E.g.: Instead of x+=5 every 0.01 second, do x+=v*dt (where v = velocity [pixels/s] and dt = time elapsed since previous update.
The first method, when done right, might give smoother graphics, but the second is easier.

To get your game further, I think I it a good exercise to convert it to OOP. Then the structure should become clearer and easier to continue with it. Choosing the right OOP structure is not easy however. I tried with my recent Tetris game: https://freebasic.net/forum/viewtopic.php?f=15&t=26306.

It all comes back to the fact that, just as knowing how to read and write doesn't mean you can write a novel, knowing how to program doesn't mean you can write a game that will capture other people's interest to play it.

I think a have game idea's which might interest others, but I never get past the initial state of writing the game engine basics.

Gallery of my stagnated (non-platform) game projects:
Image
Image
Image
Image

The last one even had working network and sound in it (although buggy).

What I had in mind for the first 2, I don't even remember :-)
BasicCoder2
Posts: 3298
Joined: Jan 01, 2009 7:03

Re: old attempt at writing a platform game

Postby BasicCoder2 » Feb 26, 2018 2:47

badidea wrote:Instead of trying to control the loop speed, you can also accept that it is difficult to control and use the loop time difference in the control.

Looking at the code I remember now giving each agent its own frame rate so for each main cycle the agents animation frame rate might be slower.
This may relate to the speed issues.
I think a have game idea's which might interest others, but I never get past the initial state of writing the game engine basics.

Yes its the other 95% that takes the most time :)
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: old attempt at writing a platform game

Postby lizard » Feb 26, 2018 4:55

BasicCoder2 wrote:It all comes back to the fact that, just as knowing how to read and write doesn't mean you can write a novel, knowing how to program doesn't mean you can write a game that will capture other people's interest to play it.

After all these years and playing thousands of games from c64 on, i never had a good idea for a completely new sort of program. Games are so much complex these days so that it takes some time to write them. Meanwhile one becomes bored by his own program. And because normally very few will have interest for the result many projects become abandoned. But the first of your screenshots looks promising, badidea.
BasicCoder2
Posts: 3298
Joined: Jan 01, 2009 7:03

Re: old attempt at writing a platform game

Postby BasicCoder2 » Feb 26, 2018 9:32

You have one up on me in that I don't actually play computer games as my interest was always in using the computer to control hardware which comes under the heading of AI software. I did most of my C64 programming in Assembler including writing a simple editor/assembler. However programming a game was an interesting challenge for me even if I never came up with a good idea for a game. I am starting again from scratch to write a simple platform game which hopefully will be easy to read and understand how it works. This is the little "hero" guy animation I just drew for the current project which I can cloth according to the game theme and modify for other characters. It is only the walking animation so I will be adding other animations as I go.
Image
lizard
Posts: 406
Joined: Oct 17, 2017 11:35
Location: Germany

Re: old attempt at writing a platform game

Postby lizard » Feb 26, 2018 9:57

Do you made this spritesheet yourself? Then you have talent. Lately i have experimented with "reiners tilesets"

https://www.reinerstilesets.de/de/

There is lot of stuff for free download and usage. But it all takes much time.

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 0 guests