PAINTER

Vragen en suggesties over het programmeren van spelletjes, sprites en dergelijke in Liberty BASIC

Moderator: anthonio

PAINTER

Berichtdoor bluatigro » wo jun 29, 2011 12:32 pm

painter is een spel waarbij je een veld moet kleuren
waarbij je er voor zorgt dat de computer-kwast vast loopt
Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
nomainwin
global winx , winy
winx = DisplayWidth
winy = DisplayHeight

dim p( winx / 20 + 2 , winy / 20 + 2 ) , cx( 2 ) , cy( 2 ) , cdx( 2 ) , cdy( 2 )

global white , red , green , hx , hy , hdx , hdy
red = 1
green = 2
open "painter" for graphics as #m
  #m "trapclose [quit]"
  #m "goto 0 0"
  #m "down"
  #m "boxfilled 20 20"
  #m "up"
  #m "goto 0 20"
  #m "down"
  #m "backcolor white"
  #m "boxfilled 20 40"
  #m "up"
  #m "getbmp white 0 0 20 40"
  #m "goto 0 20"
  #m "down"
  #m "backcolor red"
  #m "boxfilled 20 40"
  #m "up"
  #m "getbmp red 0 0 20 40"
  #m "goto 0 20"
  #m "down"
  #m "backcolor green"
  #m "boxfilled 20 40"
  #m "up"
  #m "getbmp green 0 0 20 40"
  for x = 0 to winx / 20 + 2
    for y = 0 to winy / 20 + 2
      #m "addsprite x" ; x ; "y" ; y ; " white red green"
      #m "spritexy x" ; x ; "y" ; y ; " " ; x * 20 ; " " ; y * 20
      p( x , y ) = white
    next y
  next x
  hx = int( winx / 40 )
  hy = int( winy / 40 )
   #m "setfocus"
   #m "when charaterInput [key]"
  timer 125 , [tmr]
wait
[key]
  select case right$( Inkey$ , 1 )
    case chr$( _VK_UP )
      hdx = 0
      hdy = -1
    case chr$( _VK_RIGHT )
      hdx = 1
      hdy = 0
    case chr$( _VK_DOWN )
      hdx = 0
      hdy = 1
    case chr$( _VK_LEFT )
      hdx = -1
      hdy = 0
    case else
      hdx = 0
      hdy = 0
  end select
wait
[tmr]
  #m "spriteimage x" ; hx ; "y" ; hy ; " green"
  if hx + hdx < 0 then hdx = 0
  if hx + hdx > winx / 20 then hdx = 0
  if hy + hdy < 0 then hdy = 0
  if hy + hdy > winy / 20 then hdy = 0
  hx = hx + hdx
  hy = hy + hdy
  #m "drawsprites"
wait
[quit]
  close #m
end

senario :
als je op de cursor toetsen druk zou er groene vierkantjes moeten onstaan
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Keer terug naar Games

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron