Aktuelle Zeit: 16.08.2018 02:01

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Tipps für intelligentere KI (Pfadfindung) gesucht.
BeitragVerfasst: 08.12.2017 20:35 
Offline

Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge
Hallo Leute,

ich habe mir mal SpiderBasic zugelegt und mal ein kleines Testspiel damit programmiert.
Die aktuelle KI ist aber sehr dumm.
Daher suche ich Tipps.

...und wie könnte man höhere Bildraten erzielen ? (60 Bilder pro Sekunde sind bei mir einfach nicht drin -> Hab es auf 30 Bilder pro Sekunde, weil es sonst sowie so auf 30 FPS herunterfällt.)

Code:
;Neu und sauber mit SpiderBasic

Global move = #True

#Laby = 99 ; wie Labyrinth
#Hintergrund = 0
#Mauer = 1
#Paci_Offen = 2
#Paci_Mitte1 = 3
#Paci_Mitte2 = 4
#Paci_Mitte3 = 5
#Paci_Mitte4 = 6
#Paci_Zu = 7
#Blinky = 8
#Pinky = 9
#Inky = 10
#Clyde = 11
#PacDot = 12
#PacBigDot = 13

Global Dim Level.i(20,20)

Global Dim offen.i(5)
offen(1) = 0 : offen(2) = 0 : offen(3) = 0 : offen(4) = 0

Global zufall = 1
;Global zufall_fix = 0, zfix = 0
;Global dir_ex = -1
Global direction = -1
;Global prio_x = 0, prio_y = 0

Global blinky_return.s = ""

Global paci_anim = #True

Global paci_xx = 0, paci_yy = 0
Global paci_lives = 4
Global paci_points = 0

Global paci_x = 64, paci_y = 32, paci_speed = 4
Global paci_left.b = #False, paci_right.b = #False, paci_up.b = #False, paci_down.b = #False

Global blinky_x = 320, blinky_y = 256, blinky_speed = 4
Global blinky_left.b = #False, blinky_right.b = #False, blinky_up.b = #True, blinky_down.b = #False

Global pinky_x = 320, pinky_y = 288, pinky_speed = 4
Global pinky_left.b = #False, pinky_right.b = #False, pinky_up.b = #True, pinky_down.b = #False

Global inky_x = 288, inky_y = 288, inky_speed = 2
Global inky_left.b = #False, inky_right.b = #True, inky_up.b = #False, inky_down.b = #False

Global clyde_x = 352, clyde_y = 288, clyde_speed = 2
Global clyde_left.b = #True, clyde_right.b = #False, clyde_up.b = #False, clyde_down.b = #False

Global stepping = 0
Global return_stepping = 0

Global run = 0, run2 = 0, ms = 0

InitSprite()

Procedure KI_AStern()
  ;Bitte um Tipps?
EndProcedure

Procedure Blinky_KI()
  ;Blinky_Move
  If blinky_x <= -32
    blinky_x = 640
  ElseIf blinky_x >= 640
    blinky_x = -32
  EndIf
 
  If blinky_left = #True
    blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    blinky_x = blinky_x - blinky_speed
  ElseIf blinky_right = #True
    blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    blinky_x = blinky_x + blinky_speed
  ElseIf blinky_up = #True
    blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    blinky_y = blinky_y - blinky_speed
  ElseIf blinky_down = #True
    blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    blinky_y = blinky_y + blinky_speed
  EndIf
 
  tx = Int(blinky_x / 32)
  ty = Int(blinky_y / 32)
  modx = blinky_x % 32
  mody = blinky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  If blinky_y = paci_y And blinky_x < paci_x And (blinky_left = #True Or blinky_right = #True)
    ran = 2
  ElseIf blinky_y = paci_y And blinky_x > paci_x And (blinky_left = #True Or blinky_right = #True)
    ran = 3
  ElseIf blinky_x = paci_x And blinky_y < paci_y And (blinky_up = #True Or blinky_down = #True)
    ran = 4
  ElseIf blinky_x = paci_x And blinky_y > paci_y And (blinky_up = #True Or blinky_down = #True)
    ran = 5
  Else
  ran = Int(Random(1))
  If ran = 0
    If blinky_y > paci_y
      ran = 0
    ElseIf blinky_y < paci_y
      ran = 1
    EndIf
  ElseIf ran = 1
    If blinky_x > paci_x
      ran = 0
    ElseIf blinky_x < paci_x
      ran = 1
    EndIf
  EndIf
  EndIf
 
  If blinky_x >= 32 And blinky_x <= 640 And blinky_y >= 32 And blinky_y <= 640
    If blinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Not Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Not Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_up = 1 And mody = 0 And Not Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Not Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_down = 1 And mody = 0 And Not Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    EndIf
  EndIf
EndProcedure

Procedure Pinky_KI()
  ;Pinky_Move
  If pinky_x <= -32
    pinky_x = 640
  ElseIf pinky_x >= 640
    pinky_x = -32
  EndIf
 
  If pinky_left = #True
    pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    pinky_x = pinky_x - pinky_speed
  ElseIf pinky_right = #True
    pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    pinky_x = pinky_x + pinky_speed
  ElseIf pinky_up = #True
    pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    pinky_y = pinky_y - pinky_speed
  ElseIf pinky_down = #True
    pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    pinky_y = pinky_y + pinky_speed
  EndIf
 
  tx = Int(pinky_x / 32)
  ty = Int(pinky_y / 32)
  modx = pinky_x % 32
  mody = pinky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If pinky_x >= 32 And pinky_x <= 640 And pinky_y >= 32 And pinky_y <= 640
    If pinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_right = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    EndIf
  EndIf
EndProcedure

Procedure Inky_KI()
  ;Inky_Move
  If inky_x <= -32
    inky_x = 640
  ElseIf inky_x >= 640
    inky_x = -32
  EndIf
 
  If inky_left = #True
    inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    inky_x = inky_x - inky_speed
  ElseIf inky_right = #True
    inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    inky_x = inky_x + inky_speed
  ElseIf inky_up = #True
    inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    inky_y = inky_y - inky_speed
  ElseIf inky_down = #True
    inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    inky_y = inky_y + inky_speed
  EndIf
 
  tx = Int(inky_x / 32)
  ty = Int(inky_y / 32)
  modx = inky_x % 32
  mody = inky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If inky_x >= 32 And inky_x <= 640 And inky_y >= 32 And inky_y <= 640
    If inky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_right = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    EndIf
  EndIf
EndProcedure

Procedure Clyde_KI()
  ;Clyde_Move
  If clyde_x <= -32
    clyde_x = 640
  ElseIf clyde_x >= 640
    clyde_x = -32
  EndIf
 
  If clyde_left = #True
    clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    clyde_x = clyde_x - clyde_speed
  ElseIf clyde_right = #True
    clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    clyde_x = clyde_x + clyde_speed
  ElseIf clyde_up = #True
    clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    clyde_y = clyde_y - clyde_speed
  ElseIf clyde_down = #True
    clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    clyde_y = clyde_y + clyde_speed
  EndIf
 
  tx = Int(clyde_x / 32)
  ty = Int(clyde_y / 32)
  modx = clyde_x % 32
  mody = clyde_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If clyde_x >= 32 And clyde_x <= 640 And clyde_y >= 32 And clyde_y <= 640
    If clyde_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_left = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Not Level(tx,ty-1) = 1 And Not Level(tx,ty+1) = 1 And ran = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_right = 1 And modx = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 0
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Not Level(tx-1,ty) = 1 And Not Level(tx+1,ty) = 1 And ran = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    EndIf
  EndIf
EndProcedure

Procedure CreateLevel()
  lev1.s = "1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#0#0#0#0#0#0#0#0#1#0#0#0#0#0#0#0#0#1#1#1#1#3#1#1#0#1#1#1#0#1#0#1#1#1#0#1#1#3#1#1#1#1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#1#1#1#0#1#1#0#1#0#1#1#1#1#1#0#1#0#1#1#0#1#1#1#1#0#0#0#0#1#0#0#0#1#0#0#0#1#0#0#0#0#1#1#1#1#1#1#1#0#1#1#1#2#1#2#1#1#1#0#1#1#1#1#1#2#2#2#2#1#0#1#2#2#2#2#2#2#2#1#0#1#2#2#2#2#1#1#1#1#1#0#1#2#1#1#2#1#1#2#1#0#1#1#1#1#1#0#0#0#0#0#0#2#2#1#2#2#2#1#2#2#0#0#0#0#0#0#1#1#1#1#1#0#1#2#1#1#1#1#1#2#1#0#1#1#1#1#1#2#2#2#2#1#0#1#2#2#2#2#2#2#2#1#0#1#2#2#2#2#1#1#1#1#1#0#1#2#1#1#1#1#1#2#1#0#1#1#1#1#1#1#1#0#0#0#0#0#0#0#0#1#0#0#0#0#0#0#0#0#1#1#1#1#0#1#1#0#1#1#1#0#1#0#1#1#1#0#1#1#0#1#1#1#1#3#0#1#0#0#0#0#0#0#0#0#0#0#0#1#0#3#1#1#1#1#1#0#1#0#1#0#1#1#1#1#1#0#1#0#1#0#1#1#1#1#1#0#0#0#0#1#0#0#0#1#0#0#0#1#0#0#0#0#1#1#1#1#0#1#1#1#1#1#1#0#1#0#1#1#1#1#1#1#0#1#1#1#1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#"
  x = 0 : y = 0 : a = 0 : b = 0
  For t = 1 To 442 Step 1
    If StringField(lev1, t, "#") = "1"
      DisplaySprite(#Mauer, x, y)
      Level(a,b) = 1
    ElseIf StringField(lev1, t, "#") = "0"
      DisplaySprite(#PacDot, x, y)
      Level(a,b) = 0
    ElseIf StringField(lev1, t, "#") = "2"
      Level(a,b) = 2
    ElseIf StringField(lev1, t, "#") = "3"
      DisplaySprite(#PacBigDot, x, y)
      Level(a,b) = 3
    EndIf
    If a = 20
      a = 0
      b = b + 1
      x = 0
      y = y + 32
    Else
      a = a + 1
      x = x + 32
    EndIf
  Next t
EndProcedure

Procedure DisplayLevel()
  x = 0 : y = 0 : a = 0 : b = 0
  For t = 1 To 442 Step 1
    If Level(a,b) = 1
      DisplaySprite(#Mauer, x, y)
    ElseIf Level(a,b) = 0
      DisplaySprite(#PacDot, x, y)
    ElseIf Level(a,b) = 3
      DisplaySprite(#PacBigDot, x, y)
    EndIf
    If a = 20
      a = 0
      b = b + 1
      x = 0
      y = y + 32
    Else
      a = a + 1
      x = x + 32
    EndIf
  Next t
EndProcedure

Procedure RenderFrame()
  Debug "FPS: "+Str(run2)
  ClearScreen(RGB(0,0,0))
 
  DisplayLevel()
 
  DisplaySprite(#Blinky, blinky_x, blinky_y)
  DisplaySprite(#Pinky, pinky_x, pinky_y)
  DisplaySprite(#Inky, inky_x, inky_y)
  DisplaySprite(#Clyde, clyde_x, clyde_y)
 
  If move = #True
    If return_stepping = 1
      stepping = stepping - 1
    ElseIf return_stepping = 0
      stepping = stepping + 1
    EndIf
   
    If paci_x <= -32
      paci_x = 672
    ElseIf paci_x >= 672
      paci_x = -32
    EndIf
   
    tx = Int(paci_x / 32)
    ty = Int(paci_y / 32)
    modx = paci_x % 32
    mody = paci_y % 32
   
    If tx < 1
      tx = 1
    ElseIf tx > 19
      tx = 19
    EndIf
   
    If ExamineKeyboard()
      If KeyboardPushed(#PB_Key_Left) And mody = 0 And Not Level(tx-1,ty) = 1
        paci_left = #True : paci_right = #False : paci_up = #False : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Right) And mody = 0 And Not Level(tx+1,ty) = 1
        paci_left = #False : paci_right = #True : paci_up = #False : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Up) And modx = 0 And Not Level(tx,ty-1) = 1
        paci_left = #False : paci_right = #False : paci_up = #True : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Down) And modx = 0 And Not Level(tx,ty+1) = 1
        paci_left = #False : paci_right = #False : paci_up = #False : paci_down = #True
      EndIf
    EndIf
   
    If paci_left = #True
      If Not (Level(tx-1,ty) = 1 And modx = 0)
        paci_x = paci_x - paci_speed
      EndIf
    ElseIf paci_right = #True
      If Not (Level(tx+1,ty) = 1 And modx = 0)
        paci_x = paci_x + paci_speed
      EndIf
    ElseIf paci_up = #True
      If Not (Level(tx,ty-1) = 1 And mody = 0)
        paci_y = paci_y - paci_speed
      EndIf
    ElseIf paci_down = #True
      If Not (Level(tx,ty+1) = 1 And mody = 0)
        paci_y = paci_y + paci_speed
      EndIf
    EndIf
   
    tx = Int(paci_x / 32)
    ty = Int(paci_y / 32)
   
    If tx >= 0 And tx <= 20 And ty >= 0 And ty <= 20
      If Level(tx,ty) = 0
        Level(tx,ty) = 2
      ElseIf Level(tx,ty) = 3
        Level(tx,ty) = 2
      EndIf
    EndIf
   
    If paci_anim = #True
      If stepping >= 0 And stepping < 5
        If paci_left = #True
          RotateSprite(#Paci_Offen, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Offen, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Offen, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Offen, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Offen, paci_x, paci_y)
        return_stepping = 0
      ElseIf stepping >= 5 And stepping <= 10
        If paci_left = #True
          RotateSprite(#Paci_Mitte1, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Mitte1, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Mitte1, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Mitte1, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Mitte1, paci_x, paci_y)
      ElseIf stepping >= 10 And stepping < 15
        If paci_left = #True
          RotateSprite(#Paci_Mitte2, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Mitte2, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Mitte2, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Mitte2, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Mitte2, paci_x, paci_y)
      ElseIf stepping >= 15 And stepping < 20
        If paci_left = #True
          RotateSprite(#Paci_Mitte3, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Mitte3, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Mitte3, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Mitte3, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Mitte3, paci_x, paci_y)
      ElseIf stepping >= 20 And stepping < 25
        If paci_left = #True
          RotateSprite(#Paci_Zu, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Zu, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Zu, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Zu, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Zu, paci_x, paci_y)
      ElseIf stepping >= 25
        If paci_left = #True
          RotateSprite(#Paci_Zu, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Zu, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Zu, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Zu, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Zu, paci_x, paci_y)
        return_stepping = 1
      ElseIf stepping < 0
        If paci_left = #True
          RotateSprite(#Paci_Offen, 180, #PB_Absolute)
        ElseIf paci_right = #True
          RotateSprite(#Paci_Offen, 0, #PB_Absolute)
        ElseIf paci_up = #True
          RotateSprite(#Paci_Offen, 270, #PB_Absolute)
        ElseIf paci_down = #True
          RotateSprite(#Paci_Offen, 90, #PB_Absolute)
        EndIf
        DisplaySprite(#Paci_Offen, paci_x, paci_y)
        return_stepping = 0
      EndIf
    EndIf
    Blinky_KI()
    Pinky_KI()
    Inky_KI()
    Clyde_KI()
    ;KI_DoIt(blinky_x, blinky_y)
   
;     blinky_return = KI_Move(blinky_x, blinky_y, 1)
;     blinky_x = Val(StringField(blinky_return,1,"#"))
;     blinky_y = Val(StringField(blinky_return,2,"#"))
   
    ;Debug blinky_x
    ;Debug blinky_y
  EndIf
 
  If paci_anim = #True
    If SpriteCollision(#Paci_Offen,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte1,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte2,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte3,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte4,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Zu,paci_x,paci_y,#Blinky,blinky_x,blinky_y)
     
      paci_anim = #False
      paci_left = #False : paci_right = #False : paci_up = #True : paci_down = #False
      stepping = 0
      DisplaySprite(#Paci_Offen, paci_x, paci_y)
      ;paci_lives = paci_lives - 1
      paci_x = 64 : paci_y = 32
      If paci_lives >= 0
        move = #True
        paci_anim = #True
      EndIf
    EndIf
  EndIf
 
  run = run + 1
  ms2 = ElapsedMilliseconds()
  If (ms2 - ms) >= 1000
    ms = ElapsedMilliseconds()
    run2 = run
    run = 0
  EndIf
 
  FlipBuffers()
EndProcedure

Procedure Start()
  SetFrameRate(30)
  ms = ElapsedMilliseconds()
 
  If CreateSprite(#Hintergrund, ScreenWidth(), ScreenHeight())
    If StartDrawing(SpriteOutput(#Hintergrund))
      Box(0,0,SpriteWidth(#Hintergrund),SpriteHeight(#Hintergrund),RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Mauer, 32, 32)
    If StartDrawing(SpriteOutput(#Mauer))
      Box(0,0,SpriteWidth(#Mauer),SpriteHeight(#Mauer),RGB(68, 120, 134))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Paci_Offen, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Paci_Offen))
      Ellipse(16,16,SpriteWidth(#Paci_Offen)/2,SpriteHeight(#Paci_Offen)/2,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
;    If CreateImage(#Paci_Offen, 32, 32, #PB_Sprite_AlphaBlending)
;      If StartVectorDrawing(ImageVectorOutput(#Paci_Offen))
;        AddPathArc(0, 0, 32, 32, 16)
;        StrokePath(2)
;        StopVectorDrawing()
;      EndIf
;   EndIf
 
  If CreateSprite(#Paci_Mitte1, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Paci_Mitte1))
      Ellipse(16,16,SpriteWidth(#Paci_Mitte1)/2,SpriteHeight(#Paci_Mitte1)/2,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Paci_Mitte2, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Paci_Mitte2))
      Ellipse(16,16,SpriteWidth(#Paci_Mitte2)/2,SpriteHeight(#Paci_Mitte2)/2,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Paci_Mitte3, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Paci_Mitte3))
      Ellipse(16,16,SpriteWidth(#Paci_Mitte3)/2,SpriteHeight(#Paci_Mitte3)/2,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Paci_Zu, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Paci_Zu))
      Ellipse(16,16,SpriteWidth(#Paci_Zu)/2,SpriteHeight(#Paci_Zu)/2,RGB(255,255,0))
      Line(16,16,16,1,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Blinky, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Blinky))
      Box(0,0,SpriteWidth(#Blinky),SpriteHeight(#Blinky),RGB(255,0,0))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Pinky, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Pinky))
      Box(0,0,SpriteWidth(#Pinky),SpriteHeight(#Pinky),RGB(237, 26, 133))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Inky, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Inky))
      Box(0,0,SpriteWidth(#Inky),SpriteHeight(#Inky),RGB(104, 150, 206))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#Clyde, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#Clyde))
      Box(0,0,SpriteWidth(#Clyde),SpriteHeight(#Clyde),RGB(245, 100, 43))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#PacDot, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#PacDot))
      Box(12,12,8,8,RGB(255, 239, 28))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#PacBigDot, 32, 32, #PB_Sprite_AlphaBlending)
    If StartDrawing(SpriteOutput(#PacBigDot))
      Circle(16,16,12,RGB(255, 191, 143))
      StopDrawing()
    EndIf
  EndIf
 
  CreateLevel()
 
  BindEvent(#PB_Event_RenderFrame, @RenderFrame())
  FlipBuffers()
 
EndProcedure

OpenScreen(672,672,32,"Pacman")
Start()


...ja ja... da fehlt noch einiges (aber es geht erst einmal um die KI)


Zuletzt geändert von ccode_new am 10.12.2017 19:24, insgesamt 1-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Tipps für intelligentere KI (Pfadfindung) gesucht.
BeitragVerfasst: 09.12.2017 22:44 
Offline

Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge
Wie könnte man Bilder=Images (keine Sprites) rotieren ?

Also ich bräuchte einen performanten ImageRotate-Befehl für SpiderBasic.

???

Die Performance bei vielen Sprites ist unter SpiderBasic leider viel, viel zu laaaaaangsam.

Anbei: Erstmal nicht ganz so wichtig.

Arbeite jetzt mit VectorDrawing. Da ist das rotieren der Bilder sehr einfach möglich.

z.Bsp.
Code:
If StartVectorDrawing(ImageVectorOutput(#ImageX,#PB_Unit_Pixel))
       
        MovePathCursor(200, 0)
        RotateCoordinates(200, 0, 90)
        DrawVectorImage(ImageID(#ImageY), 0)
       
        StopVectorDrawing()
      EndIf
    EndIf


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Tipps für intelligentere KI (Pfadfindung) gesucht.
BeitragVerfasst: 10.12.2017 15:36 
Offline

Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge
Wo ist der Zeichenbug ???

ClipSprite(..) und GrabSprite(.. )funktionieren nicht korrekt unter Spiderbasic.

Und das hier geht auch nicht: (Warum?)

Code:
Global move = #True

#Laby = 99 ; wie Labyrinth
#Paci = 88
#GameView = 0
#Mauer = 1
#Paci_Offen = 2
#Paci_Mitte1 = 3
#Paci_Mitte2 = 4
#Paci_Mitte3 = 5
#Paci_Zu = 6
#Blinky = 7
#Pinky = 8
#Inky = 9
#Clyde = 10
#PacDot = 11
#PacBigDot = 12

#Paci_Offen_L = 21
#Paci_Mitte1_L = 31
#Paci_Mitte2_L = 41
#Paci_Mitte3_L = 51
#Paci_Zu_L = 61

#Paci_Offen_O = 22
#Paci_Mitte1_O = 32
#Paci_Mitte2_O = 42
#Paci_Mitte3_O = 52
#Paci_Zu_O = 62

#Paci_Offen_U = 23
#Paci_Mitte1_U = 33
#Paci_Mitte2_U = 43
#Paci_Mitte3_U = 53
#Paci_Zu_U = 63

Global Dim Level.i(20,20)
Global Dim offen.i(5)
offen(1) = 0 : offen(2) = 0 : offen(3) = 0 : offen(4) = 0

Global zufall = 1
;Global zufall_fix = 0, zfix = 0
;Global dir_ex = -1
Global direction = -1
;Global prio_x = 0, prio_y = 0

Global blinky_return.s = ""

Global paci_anim = #True

Global paci_xx = 0, paci_yy = 0
Global paci_lives = 4
Global paci_points = 0

Global paci_x = 64, paci_y = 32, paci_speed = 2
Global paci_left.b = #False, paci_right.b = #False, paci_up.b = #False, paci_down.b = #False

Global blinky_x = 320, blinky_y = 256, blinky_speed = 2
Global blinky_left.b = #False, blinky_right.b = #False, blinky_up.b = #True, blinky_down.b = #False

Global pinky_x = 320, pinky_y = 288, pinky_speed = 4
Global pinky_left.b = #False, pinky_right.b = #False, pinky_up.b = #True, pinky_down.b = #False

Global inky_x = 288, inky_y = 288, inky_speed = 1
Global inky_left.b = #False, inky_right.b = #True, inky_up.b = #False, inky_down.b = #False

Global clyde_x = 352, clyde_y = 288, clyde_speed = 1
Global clyde_left.b = #True, clyde_right.b = #False, clyde_up.b = #False, clyde_down.b = #False

Global stepping = 0
Global return_stepping = 0

Global run = 0, run2 = 0, ms = 0

InitSprite()

Procedure KI_Stern()
  ;...?
EndProcedure

Procedure.s KI_Move(geist_x, geist_y, geist_speed)
  tx = Int(geist_x / 32)
  ty = Int(geist_y / 32)
  modx = geist_x % 32
  mody = geist_y % 32
 
  ;Der Weg
  If direction = 0 ;Links
    If Not (Level(tx-1,ty) = 1 And modx = 0)
      geist_x = geist_x - geist_speed
    EndIf
  ElseIf direction = 1 ;Rechts
    If Not (Level(tx+1,ty) = 1 And modx = 0)
      geist_x = geist_x + geist_speed
    EndIf
  ElseIf direction = 2 ;Oben
    If Not (Level(tx,ty-1) = 1 And mody = 0)
      geist_y = geist_y - geist_speed
    EndIf
  ElseIf direction = 3 ;Unten
    If Not (Level(tx,ty+1) = 1 And mody = 0)
      geist_y = geist_y + geist_speed
    EndIf
  EndIf
  ProcedureReturn Str(geist_x)+"#"+Str(geist_y)
EndProcedure

Procedure KI_DoIt(geist_x, geist_y)
  tx = Int(geist_x / 32)
  ty = Int(geist_y / 32)
  modx = geist_x % 32
  mody = geist_y % 32
 
  ;Die Auswertung (KI) !!!
  If geist_x > paci_x And geist_y > paci_y And Level(tx,ty-1) = 1 And mody = 0
    direction = 0 ;Links
  ElseIf geist_x > paci_x And geist_y < paci_y And Level(tx,ty+1) = 1 And mody = 0
    direction = 0 ;Links
  ElseIf geist_x < paci_x And geist_y > paci_y And Level(tx,ty-1) = 1 And mody = 0
    direction = 1 ;Rechts
  ElseIf geist_x < paci_x And geist_y < paci_y And Level(tx,ty+1) = 1 And mody = 0
    direction = 1 ;Rechts
  ElseIf geist_x > paci_x And geist_y > paci_y And Level(tx+1,ty) = 1 And modx = 0
    direction = 2 ;Oben
  ElseIf geist_x < paci_x And geist_y > paci_y And Level(tx-1,ty) = 1 And modx = 0
    direction = 2 ;Oben
  ElseIf geist_x > paci_x And geist_y < paci_y And Level(tx+1,ty) = 1 And modx = 0
    direction = 3 ;Unten
  ElseIf geist_x < paci_x And geist_y < paci_y And Level(tx-1,ty) = 1 And modx = 0
    direction = 3 ;Unten
  ElseIf geist_x > paci_x And geist_y > paci_y And Level(tx-1,ty) = 1 And modx = 0
    direction = 3 ;Unten
  EndIf
EndProcedure

Procedure Blinky_KI()
  ;Blinky_Move
  If blinky_x <= -32
    blinky_x = 640
  ElseIf blinky_x >= 640
    blinky_x = -32
  EndIf
 
  If blinky_left = #True
    blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    blinky_x = blinky_x - blinky_speed
  ElseIf blinky_right = #True
    blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    blinky_x = blinky_x + blinky_speed
  ElseIf blinky_up = #True
    blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    blinky_y = blinky_y - blinky_speed
  ElseIf blinky_down = #True
    blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    blinky_y = blinky_y + blinky_speed
  EndIf
 
  tx = Int(blinky_x / 32)
  ty = Int(blinky_y / 32)
  modx = blinky_x % 32
  mody = blinky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  If blinky_y = paci_y And blinky_x < paci_x And (blinky_left = #True Or blinky_right = #True)
    ran = 2
  ElseIf blinky_y = paci_y And blinky_x > paci_x And (blinky_left = #True Or blinky_right = #True)
    ran = 3
  ElseIf blinky_x = paci_x And blinky_y < paci_y And (blinky_up = #True Or blinky_down = #True)
    ran = 4
  ElseIf blinky_x = paci_x And blinky_y > paci_y And (blinky_up = #True Or blinky_down = #True)
    ran = 5
  Else
  ran = Int(Random(1))
  If ran = 0
    If blinky_y > paci_y
      ran = 0
    ElseIf blinky_y < paci_y
      ran = 1
    EndIf
  ElseIf ran = 1
    If blinky_x > paci_x
      ran = 0
    ElseIf blinky_x < paci_x
      ran = 1
    EndIf
  EndIf
  EndIf
 
  If blinky_x >= 32 And blinky_x <= 640 And blinky_y >= 32 And blinky_y <= 640
    If blinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx+1,ty) = 0 And ran = 2
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx-1,ty) = 0 And ran = 3
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_right = 1 And modx = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx+1,ty) = 0 And ran = 2
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx-1,ty) = 0 And ran = 3
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx+1,ty) = 1 And ran = 2
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_right = 1 And modx = 0 And Level(tx-1,ty) = 1 And ran = 3
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty+1) = 0 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty-1) = 0 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_up = 1 And mody = 0 And Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1 And (ran = 0 Or ran = 1)
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0 And (ran = 0 Or ran = 1)
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      blinky_left = #True : blinky_right = #False : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      blinky_left = #False : blinky_right = #True : blinky_up = #False : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty+1) = 0 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty-1) = 0 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty+1) = 1 And ran = 4
      blinky_left = #False : blinky_right = #False : blinky_up = #True : blinky_down = #False
    ElseIf blinky_down = 1 And mody = 0 And Level(tx,ty-1) = 1 And ran = 5
      blinky_left = #False : blinky_right = #False : blinky_up = #False : blinky_down = #True
    EndIf
  EndIf
EndProcedure

Procedure Pinky_KI()
  ;Pinky_Move
  If pinky_x <= -32
    pinky_x = 640
  ElseIf pinky_x >= 640
    pinky_x = -32
  EndIf
 
  If pinky_left = #True
    pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    pinky_x = pinky_x - pinky_speed
  ElseIf pinky_right = #True
    pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    pinky_x = pinky_x + pinky_speed
  ElseIf pinky_up = #True
    pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    pinky_y = pinky_y - pinky_speed
  ElseIf pinky_down = #True
    pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    pinky_y = pinky_y + pinky_speed
  EndIf
 
  tx = Int(pinky_x / 32)
  ty = Int(pinky_y / 32)
  modx = pinky_x % 32
  mody = pinky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If pinky_x >= 32 And pinky_x <= 640 And pinky_y >= 32 And pinky_y <= 640
    If pinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      pinky_left = #False : pinky_right = #False : pinky_up = #True : pinky_down = #False
    ElseIf pinky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      pinky_left = #False : pinky_right = #False : pinky_up = #False : pinky_down = #True
    ElseIf pinky_right = 1 And modx = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      pinky_left = #True : pinky_right = #False : pinky_up = #False : pinky_down = #False
    ElseIf pinky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      pinky_left = #False : pinky_right = #True : pinky_up = #False : pinky_down = #False
    EndIf
  EndIf
EndProcedure

Procedure Inky_KI()
  ;Inky_Move
  If inky_x <= -32
    inky_x = 640
  ElseIf inky_x >= 640
    inky_x = -32
  EndIf
 
  If inky_left = #True
    inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    inky_x = inky_x - inky_speed
  ElseIf inky_right = #True
    inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    inky_x = inky_x + inky_speed
  ElseIf inky_up = #True
    inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    inky_y = inky_y - inky_speed
  ElseIf inky_down = #True
    inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    inky_y = inky_y + inky_speed
  EndIf
 
  tx = Int(inky_x / 32)
  ty = Int(inky_y / 32)
  modx = inky_x % 32
  mody = inky_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If inky_x >= 32 And inky_x <= 640 And inky_y >= 32 And inky_y <= 640
    If inky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      inky_left = #False : inky_right = #False : inky_up = #True : inky_down = #False
    ElseIf inky_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      inky_left = #False : inky_right = #False : inky_up = #False : inky_down = #True
    ElseIf inky_right = 1 And modx = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      inky_left = #True : inky_right = #False : inky_up = #False : inky_down = #False
    ElseIf inky_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      inky_left = #False : inky_right = #True : inky_up = #False : inky_down = #False
    EndIf
  EndIf
EndProcedure

Procedure Clyde_KI()
  ;Clyde_Move
  If clyde_x <= -32
    clyde_x = 640
  ElseIf clyde_x >= 640
    clyde_x = -32
  EndIf
 
  If clyde_left = #True
    clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    clyde_x = clyde_x - clyde_speed
  ElseIf clyde_right = #True
    clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    clyde_x = clyde_x + clyde_speed
  ElseIf clyde_up = #True
    clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    clyde_y = clyde_y - clyde_speed
  ElseIf clyde_down = #True
    clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    clyde_y = clyde_y + clyde_speed
  EndIf
 
  tx = Int(clyde_x / 32)
  ty = Int(clyde_y / 32)
  modx = clyde_x % 32
  mody = clyde_y % 32
 
  If tx = 0
    tx = 1
  ElseIf tx > 19
    tx = 19
  EndIf
 
  ran = Int(Random(1))
 
  If clyde_x >= 32 And clyde_x <= 640 And clyde_y >= 32 And clyde_y <= 640
    If clyde_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_left = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_left = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_left = 1 And modx = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Level(tx,ty-1) = 1 And Level(tx,ty+1) = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 0
      clyde_left = #False : clyde_right = #False : clyde_up = #True : clyde_down = #False
    ElseIf clyde_right = 1 And modx = 0 And Level(tx,ty-1) = 0 And Level(tx,ty+1) = 0 And ran = 1
      clyde_left = #False : clyde_right = #False : clyde_up = #False : clyde_down = #True
    ElseIf clyde_right = 1 And modx = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_up = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 1
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Level(tx-1,ty) = 1 And Level(tx+1,ty) = 0
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 0
      clyde_left = #True : clyde_right = #False : clyde_up = #False : clyde_down = #False
    ElseIf clyde_down = 1 And mody = 0 And Level(tx-1,ty) = 0 And Level(tx+1,ty) = 0 And ran = 1
      clyde_left = #False : clyde_right = #True : clyde_up = #False : clyde_down = #False
    EndIf
  EndIf
EndProcedure

Procedure RotateImage(bild, tmp_bild, winkel)
  If CreateImage(tmp_bild, 32, 32)
    If StartVectorDrawing(ImageVectorOutput(tmp_bild, #PB_Unit_Pixel))
      MovePathCursor(0, 0)
      RotateCoordinates(16, 16, winkel)
      DrawVectorImage(ImageID(bild))
     
      StopVectorDrawing()
    EndIf
  EndIf
EndProcedure

Procedure RenderFrame()
  ;Debug "FPS: "+Str(run2)
  ClearScreen(RGB(0,0,0))
 
  If StartDrawing(SpriteOutput(#GameView))
    Box(0,0,SpriteWidth(#GameView),SpriteHeight(#GameView),RGB(0,0,0))
    DrawImage(ImageID(#Laby), 0, 0)
    DrawImage(ImageID(#Paci_Offen_L), paci_x, paci_y)
    DrawImage(ImageID(#Blinky), blinky_x, blinky_y)
    DrawImage(ImageID(#Pinky), pinky_x, pinky_y)
    DrawImage(ImageID(#Inky), inky_x, inky_y)
    DrawImage(ImageID(#Clyde), clyde_x, clyde_y)
    StopDrawing()
  EndIf
 
  If move = #True
    If return_stepping = 1
      stepping = stepping - 1
    ElseIf return_stepping = 0
      stepping = stepping + 1
    EndIf
   
    If paci_x <= -32
      paci_x = 672
    ElseIf paci_x >= 672
      paci_x = -32
    EndIf
   
    tx = Int(paci_x / 32)
    ty = Int(paci_y / 32)
    modx = paci_x % 32
    mody = paci_y % 32
   
    If tx = 0
      tx = 1
    ElseIf tx > 19
      tx = 19
    EndIf
   
    If ExamineKeyboard()
      If KeyboardPushed(#PB_Key_Left) And mody = 0 And Not Level(tx-1,ty) = 1
        paci_left = #True : paci_right = #False : paci_up = #False : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Right) And mody = 0 And Not Level(tx+1,ty) = 1
        paci_left = #False : paci_right = #True : paci_up = #False : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Up) And modx = 0 And Not Level(tx,ty-1) = 1
        paci_left = #False : paci_right = #False : paci_up = #True : paci_down = #False
      ElseIf KeyboardPushed(#PB_Key_Down) And modx = 0 And Not Level(tx,ty+1) = 1
        paci_left = #False : paci_right = #False : paci_up = #False : paci_down = #True
      EndIf
    EndIf
   
    If paci_left = #True
      If Not (Level(tx-1,ty) = 1 And modx = 0)
        paci_x = paci_x - paci_speed
      EndIf
    ElseIf paci_right = #True
      If Not (Level(tx+1,ty) = 1 And modx = 0)
        paci_x = paci_x + paci_speed
      EndIf
    ElseIf paci_up = #True
      If Not (Level(tx,ty-1) = 1 And mody = 0)
        paci_y = paci_y - paci_speed
      EndIf
    ElseIf paci_down = #True
      If Not (Level(tx,ty+1) = 1 And mody = 0)
        paci_y = paci_y + paci_speed
      EndIf
    EndIf
   
    If paci_anim = #True
      If stepping >= 0 And stepping < 5
        If paci_left = #True
          ;RotateSprite(#Paci_Offen, 180, #PB_Absolute)
          ;RotateImage(#Paci_Offen, #tmp_image, 180)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Offen, 0, #PB_Absolute)
          ;RotateImage(#Paci_Offen, #tmp_image, 0)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Offen, 270, #PB_Absolute)
          ;RotateImage(#Paci_Offen, #tmp_image, 270)
        ElseIf paci_down = #True
          ;RotateImage(#Paci_Offen, #tmp_image, 90)
        EndIf
        ;DisplayTransparentSprite(#Paci_Offen, paci_x, paci_y)
;         If StartDrawing(SpriteOutput(#GameView))
;           DrawImage(ImageID(#tmp_image), paci_x, paci_y)
;           StopDrawing()
;         EndIf
        return_stepping = 0
      ElseIf stepping >= 5 And stepping <= 10
        If paci_left = #True
          ;RotateSprite(#Paci_Mitte1, 180, #PB_Absolute)
          ;RotateImage(#Paci_Mitte1, 55, 180)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Mitte1, 0, #PB_Absolute)
          ;RotateImage(#Paci_Mitte1, 55, 0)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Mitte1, 270, #PB_Absolute)
          ;RotateImage(#Paci_Mitte1, 55, 270)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Mitte1, 90, #PB_Absolute)
          ;RotateImage(#Paci_Mitte1, 55, 90)
        EndIf
        ;DisplayTransparentSprite(#Paci_Mitte1, paci_x, paci_y)
;         If StartDrawing(SpriteOutput(#GameView))
;           DrawImage(ImageID(55), paci_x, paci_y)
;           StopDrawing()
;         EndIf
;         FreeImage(55)
      ElseIf stepping >= 10 And stepping < 15
        If paci_left = #True
          ;RotateSprite(#Paci_Mitte2, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Mitte2, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Mitte2, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Mitte2, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Mitte2, paci_x, paci_y)
      ElseIf stepping >= 15 And stepping < 20
        If paci_left = #True
          ;RotateSprite(#Paci_Mitte3, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Mitte3, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Mitte3, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Mitte3, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Mitte3, paci_x, paci_y)
      ElseIf stepping >= 20 And stepping < 25
        If paci_left = #True
          ;RotateSprite(#Paci_Mitte4, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Mitte4, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Mitte4, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Mitte4, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Mitte4, paci_x, paci_y)
      ElseIf stepping >= 25 And stepping < 30
        If paci_left = #True
          ;RotateSprite(#Paci_Zu, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Zu, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Zu, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Zu, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Zu, paci_x, paci_y)
      ElseIf stepping >= 30
        If paci_left = #True
          ;RotateSprite(#Paci_Zu, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Zu, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Zu, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Zu, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Zu, paci_x, paci_y)
        return_stepping = 1
      ElseIf stepping < 0
        If paci_left = #True
          ;RotateSprite(#Paci_Offen, 180, #PB_Absolute)
        ElseIf paci_right = #True
          ;RotateSprite(#Paci_Offen, 0, #PB_Absolute)
        ElseIf paci_up = #True
          ;RotateSprite(#Paci_Offen, 270, #PB_Absolute)
        ElseIf paci_down = #True
          ;RotateSprite(#Paci_Offen, 90, #PB_Absolute)
        EndIf
        ;DisplayTransparentSprite(#Paci_Offen, paci_x, paci_y)
        return_stepping = 0
      EndIf
    EndIf
    Blinky_KI()
    Pinky_KI()
    Inky_KI()
    Clyde_KI()
    ;KI_DoIt(blinky_x, blinky_y)
   
;     blinky_return = KI_Move(blinky_x, blinky_y, 1)
;     blinky_x = Val(StringField(blinky_return,1,"#"))
;     blinky_y = Val(StringField(blinky_return,2,"#"))
   
    ;Debug blinky_x
    ;Debug blinky_y
  EndIf
 
  If paci_anim = #True
    If SpriteCollision(#Paci_Offen,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte1,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte2,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Mitte3,paci_x,paci_y,#Blinky,blinky_x,blinky_y) Or
       SpriteCollision(#Paci_Zu,paci_x,paci_y,#Blinky,blinky_x,blinky_y)
     
      paci_anim = #False
      paci_left = #False : paci_right = #False : paci_up = #True : paci_down = #False
      stepping = 0
      ;DisplayTransparentSprite(#Paci_Offen, paci_x, paci_y, 200)
      ;paci_lives = paci_lives - 1
      paci_x = 64 : paci_y = 32
      If paci_lives >= 0
        move = #True
        paci_anim = #True
      EndIf
    EndIf
  EndIf
 
  DisplayTransparentSprite(#GameView,0,0)
 
  run = run + 1
  ms2 = ElapsedMilliseconds()
  If (ms2 - ms) >= 1000
    ms = ElapsedMilliseconds()
    run2 = run
    run = 0
  EndIf
 
  FlipBuffers()
EndProcedure

Procedure Start()
  SetFrameRate(60)
  ms = ElapsedMilliseconds()
 
  If CreateImage(#Mauer, 32, 32)
    If StartDrawing(ImageOutput(#Mauer))
      Box(0,0,ImageWidth(#Mauer),ImageHeight(#Mauer),RGB(68, 120, 134))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci, 640, 32)
    If StartDrawing(ImageOutput(#Paci))
      ;Paci_Offen_R
      Ellipse(16,16,16,16,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte1_R
      Ellipse(48,16,16,16,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(48,16,16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte2_R
      Ellipse(80,16,16,16,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(80,16,16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte3_R
      Ellipse(112,16,16,16,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(112,16,16,k,RGB(0,0,0))
      Next k
      ;Paci_Zu_R
      Ellipse(144,16,16,16,RGB(255,255,0))
      Line(144,16,16,1,RGB(0,0,0))
      ;...
      ;Paci_Offen_L
      Ellipse(176,16,16,16,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(176,16,-16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte1_L
      Ellipse(208,16,16,16,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(208,16,-16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte2_L
      Ellipse(240,16,16,16,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(240,16,-16,k,RGB(0,0,0))
      Next k
      ;Paci_Mitte3_L
      Ellipse(272,16,16,16,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(272,16,-16,k,RGB(0,0,0))
      Next k
      ;Paci_Zu_L
      Ellipse(304,16,16,16,RGB(255,255,0))
      Line(304,16,-16,1,RGB(0,0,0))
      ;...
      ;Paci_Offen_O
      Ellipse(336,16,16,16,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(336,16,k,-16,RGB(0,0,0))
      Next k
      ;Paci_Mitte1_O
      Ellipse(368,16,16,16,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(368,16,k,-16,RGB(0,0,0))
      Next k
      ;Paci_Mitte2_O
      Ellipse(400,16,16,16,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(400,16,k,-16,RGB(0,0,0))
      Next k
      ;Paci_Mitte3_O
      Ellipse(432,16,16,16,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(432,16,k,-16,RGB(0,0,0))
      Next k
      ;Paci_Zu_O
      Ellipse(464,16,16,16,RGB(255,255,0))
      Line(464,16,1,-16,RGB(0,0,0))
      ;...
      ;Paci_Offen_U
      Ellipse(496,16,16,16,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(496,16,k,16,RGB(0,0,0))
      Next k
      ;Paci_Mitte1_U
      Ellipse(528,16,16,16,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(528,16,k,16,RGB(0,0,0))
      Next k
      ;Paci_Mitte2_U
      Ellipse(560,16,16,16,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(560,16,k,16,RGB(0,0,0))
      Next k
      ;Paci_Mitte3_U
      Ellipse(592,16,16,16,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(592,16,k,16,RGB(0,0,0))
      Next k
      ;Paci_Zu_U
      Ellipse(624,16,16,16,RGB(255,255,0))
      Line(624,16,1,16,RGB(0,0,0))
      ;...
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci_Offen, 32, 32)
    If StartDrawing(ImageOutput(#Paci_Offen))
      Ellipse(16,16,ImageWidth(#Paci_Offen)/2,ImageHeight(#Paci_Offen)/2,RGB(255,255,0))
      For k = -16 To 16 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci_Mitte1, 32, 32)
    If StartDrawing(ImageOutput(#Paci_Mitte1))
      Ellipse(16,16,ImageWidth(#Paci_Mitte1)/2,ImageHeight(#Paci_Mitte1)/2,RGB(255,255,0))
      For k = -12 To 12 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci_Mitte2, 32, 32)
    If StartDrawing(ImageOutput(#Paci_Mitte2))
      Ellipse(16,16,ImageWidth(#Paci_Mitte2)/2,ImageHeight(#Paci_Mitte2)/2,RGB(255,255,0))
      For k = -8 To 8 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci_Mitte3, 32, 32)
    If StartDrawing(ImageOutput(#Paci_Mitte3))
      Ellipse(16,16,ImageWidth(#Paci_Mitte3)/2,ImageHeight(#Paci_Mitte3)/2,RGB(255,255,0))
      For k = -4 To 4 Step 1
        Line(16,16,16,k,RGB(0,0,0))
      Next k
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Paci_Zu, 32, 32)
    If StartDrawing(ImageOutput(#Paci_Zu))
      Ellipse(16,16,ImageWidth(#Paci_Zu)/2,ImageHeight(#Paci_Zu)/2,RGB(255,255,0))
      Line(16,16,16,0,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Blinky, 32, 32)
    If StartDrawing(ImageOutput(#Blinky))
      Box(0,0,ImageWidth(#Blinky),ImageHeight(#Blinky),RGB(255,0,0))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Pinky, 32, 32)
    If StartDrawing(ImageOutput(#Pinky))
      Box(0,0,ImageWidth(#Pinky),ImageHeight(#Pinky),RGB(237, 26, 133))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Inky, 32, 32)
    If StartDrawing(ImageOutput(#Inky))
      Box(0,0,ImageWidth(#Inky),ImageHeight(#Inky),RGB(104, 150, 206))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Clyde, 32, 32)
    If StartDrawing(ImageOutput(#Clyde))
      Box(0,0,ImageWidth(#Clyde),ImageHeight(#Clyde),RGB(245, 100, 43))
      Box(6,4,9,9,RGB(0,0,0))
      Box(19,4,9,9,RGB(0,0,0))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#PacDot, 32, 32)
    If StartDrawing(ImageOutput(#PacDot))
      Box(12,12,8,8,RGB(255, 239, 28))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#PacBigDot, 2, 2)
    If StartDrawing(ImageOutput(#PacBigDot))
      Circle(16,16,12,RGB(255, 191, 143))
      StopDrawing()
    EndIf
  EndIf
 
  If CreateImage(#Laby, 672, 672)
    If StartDrawing(ImageOutput(#Laby))
      lev1.s = "1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#0#0#0#0#0#0#0#0#1#0#0#0#0#0#0#0#0#1#1#1#1#3#1#1#0#1#1#1#0#1#0#1#1#1#0#1#1#3#1#1#1#1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#1#1#1#0#1#1#0#1#0#1#1#1#1#1#0#1#0#1#1#0#1#1#1#1#0#0#0#0#1#0#0#0#1#0#0#0#1#0#0#0#0#1#1#1#1#1#1#1#0#1#1#1#2#1#2#1#1#1#0#1#1#1#1#1#2#2#2#2#1#0#1#2#2#2#2#2#2#2#1#0#1#2#2#2#2#1#1#1#1#1#0#1#2#1#1#2#1#1#2#1#0#1#1#1#1#1#0#0#0#0#0#0#2#2#1#2#2#2#1#2#2#0#0#0#0#0#0#1#1#1#1#1#0#1#2#1#1#1#1#1#2#1#0#1#1#1#1#1#2#2#2#2#1#0#1#2#2#2#2#2#2#2#1#0#1#2#2#2#2#1#1#1#1#1#0#1#2#1#1#1#1#1#2#1#0#1#1#1#1#1#1#1#0#0#0#0#0#0#0#0#1#0#0#0#0#0#0#0#0#1#1#1#1#0#1#1#0#1#1#1#0#1#0#1#1#1#0#1#1#0#1#1#1#1#3#0#1#0#0#0#0#0#0#0#0#0#0#0#1#0#3#1#1#1#1#1#0#1#0#1#0#1#1#1#1#1#0#1#0#1#0#1#1#1#1#1#0#0#0#0#1#0#0#0#1#0#0#0#1#0#0#0#0#1#1#1#1#0#1#1#1#1#1#1#0#1#0#1#1#1#1#1#1#0#1#1#1#1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#"
      x = 0 : y = 0 : a = 0 : b = 0
      For t = 1 To 442 Step 1
        If StringField(lev1, t, "#") = "1"
          DrawImage(ImageID(#Mauer), x, y)
          Level(a,b) = 1
        ElseIf StringField(lev1, t, "#") = "0"
          DrawImage(ImageID(#PacDot), x, y)
          Level(a,b) = 0
        ElseIf StringField(lev1, t, "#") = "2"
          Level(a,b) = 0
        ElseIf StringField(lev1, t, "#") = "3"
          DrawImage(ImageID(#PacBigDot), x, y)
          Level(a,b) = 0
        EndIf
        If a = 20
          a = 0
          b = b + 1
          x = 0
          y = y + 32
        Else
          a = a + 1
          x = x + 32
        EndIf
      Next t
      StopDrawing()
    EndIf
  EndIf
 
  If CreateSprite(#GameView, ScreenWidth(), ScreenHeight())
    If StartDrawing(SpriteOutput(#GameView))
      Box(0,0,SpriteWidth(#GameView),SpriteHeight(#GameView),RGB(0,0,0))
      DrawImage(ImageID(#Laby), 0, 0)
      StopDrawing()
    EndIf
  EndIf
 
  RotateImage(#Paci_Offen, #Paci_Offen_L, 180)
  RotateImage(#Paci_Offen, #Paci_Offen_O, 270)
  ;RotateImage(#Paci_Offen, #Paci_Offen_U, 90)
;   
;   RotateImage(#Paci_Mitte1, #Paci_Mitte1_L, 180)
;   RotateImage(#Paci_Mitte1, #Paci_Mitte1_O, 270)
;   RotateImage(#Paci_Mitte1, #Paci_Mitte1_U, 90)
;   
;   RotateImage(#Paci_Mitte2, #Paci_Mitte2_L, 180)
;   RotateImage(#Paci_Mitte2, #Paci_Mitte2_O, 270)
;   RotateImage(#Paci_Mitte2, #Paci_Mitte2_U, 90)
;   
;   RotateImage(#Paci_Mitte3, #Paci_Mitte3_L, 180)
;   RotateImage(#Paci_Mitte3, #Paci_Mitte3_O, 270)
;   RotateImage(#Paci_Mitte3, #Paci_Mitte3_U, 90)
;   
;   RotateImage(#Paci_Zu, #Paci_Zu_L, 180)
;   RotateImage(#Paci_Zu, #Paci_Zu_O, 270)
;   RotateImage(#Paci_Zu, #Paci_Zu_U, 90)
 
  BindEvent(#PB_Event_RenderFrame, @RenderFrame())
  FlipBuffers()
 
EndProcedure

OpenScreen(672,672,32,"Pacman")
Start()


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  
cron

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye