Board Logo
« platform : blocks »

Welcome Guest. Please Login or Register.
Jan 16th, 2018, 3:38pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: platform : blocks  (Read 702 times)
bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx platform : blocks
« Thread started on: Jul 6th, 2016, 04:55am »


try at a platform game

instuctions :
use left right cursor to move
use space to jump
you cant jump in a jump
if you hit bottom game ends
try to go right as posible

to the gamers :
how do i inprove the gameplay ?

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global b.max,winx,winy,mouse.x,mouse.y,key$,player.dy,jumping
b.max = 50
winx = WindowWidth
winy = WindowHeight
dim x(b.max),y(b.max)
dim dx(b.max),dy(b.max)
for i = 1 to b.max
  x(i)=range(0,winx-30)
  y(i)=range(0,winy-10)
next i
nomainwin
open "blocks 3" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  #m "getbmp background 0 0 2 2"
  #m "background background"
  #m "goto 0 0"
  #m "backcolor black"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "goto 0 10"
  #m "backcolor green"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "getbmp block 0 0 30 20"
  #m "goto 0 10"
  #m "backcolor white"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "getbmp player 0 0 10 20"
  for i = 0 to b.max
    #m "addsprite block";i;" block"
    #m "spritexy block";i;" ";x(i);" ";y(i)
  next i
  #m "addsprite player player"
  #m "spritexy player ";winx/2;" ";winy/2


  #m "when mouseMove [move]"
  #m "when characterInput [key]"
  #m "setfocus"
  timer 40 , [timer]
wait
[timer]
  scan
  for i = 0 to b.max
    call block.update i
    #m "spritexy block";i;" ";x(i);" ";y(i)
    if x(i) < 0 then
      x(i)=winx
      y(i)=range(0,winy-10)
    end if
    dx(i)=0
  next i
  player.dy=player.dy+0.1
  #m "spritexy? player x y"
  #m "spritecollides player hit$"
  if len( hit$ ) then
    player.dy = -1
    jumping = 0
  end if
  y=y+player.dy
  #m "spritexy player ";x;" ";y
  select case key$
    case chr$( _VK_RIGHT )
      for i = 0 to b.max
        dx(i) = -5
      next i
    case chr$( _VK_LEFT )
      for i = 1 to b.max
        dx(i) = 5
      next i
    case chr$( _VK_SPACE )
      if not( jumping ) then
        player.dy = -5
        jumping=1
      end if
    case else
  end select
  key$=""
  if y>winy then
    goto [quit]
  end if
  #m "drawsprites"
wait
[move]
  mouse.x = MouseX
  mouse.y = MouseY
wait
[key]
  key$ = right$( Inkey$ , 1 )
  if key$ <> chr$( 27 ) then wait
[quit]
  close #m
end
sub block.update no
  x(no)=x(no)+dx(no)
  y(no)=y(no)+dy(no)
end sub
function range( l , h )
  range = rnd(0)*(h-l)+l
end function
 
User IP Logged

rcdronan
Guest
xx Re: platform : blocks
« Reply #1 on: Jul 6th, 2016, 3:42pm »

Nice prototype. To improve this game I would make it so that whenever you're pressing the left or right keys the screen moves more easily and you don't have to keep pressing the keys continuously to move.
User IP Logged

bluatigro
Full Member
ImageImageImageImage


member is offline

Avatar

cxio difersas el tio respondas cxio samvaloras [ thats esperanto for : everybody is different therefore everybody is equal ]


PM

Gender: Male
Posts: 229
xx Re: platform : blocks
« Reply #2 on: Jul 7th, 2016, 04:42am »

@rcdronan :
ok lets try that

update :
point system added
Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global b.max,winx,winy,points,key$,player.dy
b.max = 50
winx = WindowWidth
winy = WindowHeight
dim x(b.max),y(b.max)
dim dx(b.max),dy(b.max)
for i = 1 to b.max
  x(i)=range(0,winx-30)
  y(i)=range(0,winy-10)
next i
nomainwin
open "blocks 3" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  #m "getbmp background 0 0 2 2"
  #m "background background"
  #m "goto 0 0"
  #m "backcolor black"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "goto 0 10"
  #m "backcolor green"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "getbmp block 0 0 30 20"
  #m "goto 0 10"
  #m "backcolor white"
  #m "down"
  #m "boxfilled 30 20"
  #m "up"
  #m "getbmp player 0 0 10 20"
  for i = 0 to b.max
    #m "addsprite block";i;" block"
    #m "spritexy block";i;" ";x(i);" ";y(i)
  next i
  #m "addsprite player player"
  #m "spritexy player ";winx/2;" ";winy/2
  #m "font courier_new 30 bold"
  for i = 0 to 9
    #m "goto 0 30"
    #m "color black"
    #m "backcolor white"
    #m "down"
    #m "\";i
    #m "up"
    #m "goto 0 100"
    #m "color pink"
    #m "backcolor black"
    #m "down"
    #m "\";i
    #m "up"
    #m "getbmp digit";i;" 0 0 30 140"
    anim$ = anim$ + " digit";i
  next i
  for i = 1 to 12
    #m "addsprite digit";i;" ";anim$
    #m "spritexy digit";i;" ";500-i*30;" 30"
  next i
  #m "when characterInput [key]"
  #m "setfocus"
  timer 40 , [timer]
wait
[timer]
  scan
  for i = 1 to 9
    #m "spriteimage digit";i;" digit 0"
  next i
  for i = 1 to len( str$( points ) )
    digit = val( mid$( str$( points ) , i , 1 ) )
    #m "spriteimage digit";i;" digit";digit
  next i

  for i = 0 to b.max
    call block.update i
    #m "spritexy block";i;" ";x(i);" ";y(i)
    if x(i) < 0 then
      x(i)=winx
      y(i)=range(0,winy-10)
    end if
    dx(i)=0
  next i
  player.dy=player.dy+0.1
  #m "spritexy? player x y"
  #m "spritecollides player hit$"
  if len( hit$ ) then
    player.dy = -1
    jumping = 0
      #m "spritexy? ";word$(hit$,1);" otherx othery" '******************
      #m "spritexy player ";x;" ";othery-10
     '   print otherx,othery
     ' print word$(hit$,1)
  else
    y=y+player.dy
    #m "spritexy player ";x;" ";y
  end if
  select case key$
    case chr$( _VK_RIGHT )
      for i = 0 to b.max
        dx(i) = -5
      next i
      points = points + 1
    case chr$( _VK_LEFT )
      for i = 1 to b.max
        dx(i) = 5
      next i
      points = points - 1
    case chr$( _VK_SPACE )
      if not( jumping ) then
        player.dy = -5
        jumping = 1
      end if
    case else
  end select
''  key$=""
  if y>winy then
    goto [quit]
  end if
  #m "drawsprites"
wait
[key]
  key$ = right$( Inkey$ , 1 )
  if key$ <> chr$( 27 ) then wait
[quit]
  close #m
end
sub block.update no
  x(no)=x(no)+dx(no)
  y(no)=y(no)+dy(no)
end sub
function range( l , h )
  range = rnd(0)*(h-l)+l
end function
 
« Last Edit: Jul 7th, 2016, 04:46am by bluatigro » User IP Logged

CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 155
xx Re: platform : blocks
« Reply #3 on: Jul 7th, 2016, 08:26am »

That's fun.

Next stop, Space Invaders.

-Carl
User IP Logged

tanger32au
Full Member
ImageImageImageImage


member is offline

Avatar



YIM YIM
Homepage PM

Gender: Male
Posts: 135
xx Re: platform : blocks
« Reply #4 on: Aug 23rd, 2017, 12:45am »

I love this, I am going to add it as a bonus in my latest program.
User IP Logged

http://launcestonanalyticalradioscanning.blogspot.com.au/

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls