Problem beim scrollen

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

Shinkiro1

ehemals "Espada"

Betreff: Problem beim scrollen

BeitragMo, Mai 04, 2009 15:45
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo liebe Community!
Ich bin gerade dabei mir ein kleine RPG Engine zu basteln. Scrollen funktioniert ja eigentlich,
nur gibt es da ein Problem. Jedes mal wenn ich an einen Rand stoße, wird der scrollview um eine
Tilebreite(32 px) verschoben.
Hier ist der code:

Code: [AUSKLAPPEN]

Function PlayerInput()
   
   
   
   If KeyDown(KEY_UP) ;....................................... OBEN
      direction = OBEN
      If hero\y < 1 Then hero\y = 1
      
      If maparray(hero\x,hero\y-1,3) = 0
         hero\y = hero\y - 1
         If Not hero\y < 1
            map_scrolly = map_scrolly - TSIZE
         EndIf
         
      EndIf
   
   
   ElseIf KeyDown(KEY_DOWN) ;....................................... UNTEN
      direction = UNTEN
      If hero\y > map_y-2 Then hero\y = map_y-2
      
      If maparray(hero\x,hero\y+1,3) = 0
         hero\y = hero\y + 1
         If Not hero\y > map_y-2
            map_scrolly = map_scrolly + TSIZE
         EndIf
         
      EndIf
   
   ElseIf KeyDown(KEY_LEFT) ;....................................... LINKS
      direction = LINKS
      If hero\x < 1 Then hero\x = 1
      
      If maparray(hero\x-1,hero\y,3) = 0
         hero\x = hero\x - 1
         If Not hero\x < 1
            map_scrollx = map_scrollx - TSIZE
         EndIf
         
      EndIf
      
   ElseIf KeyDown(KEY_RIGHT) ;....................................... RECHTS
      direction = RECHTS
      If hero\x > map_x-2 Then hero\x = map_x-2
      
      If maparray(hero\x+1,hero\y,3) = 0
         hero\x = hero\x + 1
         If Not hero\x > map_x-2
            map_scrollx = map_scrollx + TSIZE
         EndIf
         
      EndIf
   
End Function


Ich hab da schon einiges probiert aber bin nicht draufgekommen das problem zu umgehen.

mfg
Espada
Blog :: Ein RPG in 3 Monaten erstellen
Twitter :: News zum Projekt
 

counter_terrorist_123

BeitragFr, Mai 08, 2009 20:09
Antworten mit Zitat
Benutzer-Profile anzeigen
http://lmgtfy.com/?q=Problem+b...litz+Basic
WHO is the KING ?

I am the KING

Shinkiro1

ehemals "Espada"

BeitragSa, Mai 09, 2009 14:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Herzlichen Dank counter_terrorist_123, aber die Board Suche habe ich selbstverständlich schon vorher benutzt Wink

Naja, dann werd ich meinen ganzen code nochmal verwerfen und die function neu schreiben, bevor ich ewig dran sitze.
Blog :: Ein RPG in 3 Monaten erstellen
Twitter :: News zum Projekt

SpionAtom

BeitragSa, Mai 09, 2009 16:05
Antworten mit Zitat
Benutzer-Profile anzeigen
Das Problem bei solchen Codes ist, dass man sie nicht Out-of-the-box benutzen kann. Man muss sich einen Teil dazuschreiben, um zu sehen, was der Code anstellt. Da haben die wenigsten Leute Bock drauf.

Wie dem auch sei, ich hab mir das angeschaut, und bisher noch nichts gefunden Confused
os: Windows 10 Home cpu: Intel Core i7 6700K 4.00Ghz gpu: NVIDIA GeForce GTX 1080

SpionAtom

BeitragSa, Mai 09, 2009 16:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
Const KEY_UP = 200, KEY_DOWN = 208, KEY_LEFT = 203, KEY_RIGHT = 205
Const map_x = 40, map_y = 40
Dim maparray(map_x, map_y, 3)
Type Hero
   Field x, y
End Type
Global hero.hero, map_scrollx, map_scrolly, TSIZE

hero = New Hero
hero\x = 20
hero\y = 20
TSIZE = 20

   Graphics 800, 600, 0, 2
   SetBuffer BackBuffer()
   
   Repeat            
      PlayerInput()   
   
      Cls   
      For i = 0 To 39
      For j = 0 To 39
         Rect -map_scrollx + i * TSIZE, -map_scrolly + j * TSIZE, TSIZE, TSIZE, 0
         If i = hero\x And j = hero\y Then Oval -map_scrollx + i * TSIZE, -map_scrolly + j * TSIZE, TSIZE, TSIZE
      Next
      Next            
      
      Flip()   
      Delay 50   
   
   Until KeyDown(1)
   End

Function PlayerInput()
   
   
   
   If KeyDown(KEY_UP) ;....................................... OBEN
      direction = OBEN
      If hero\y < 1 Then hero\y = 1
     
      If maparray(hero\x,hero\y-1,3) = 0
         hero\y = hero\y - 1
         If Not hero\y < 1
            map_scrolly = map_scrolly - TSIZE
         EndIf
         
      EndIf
   
   
   ElseIf KeyDown(KEY_DOWN) ;....................................... UNTEN
      direction = UNTEN
      If hero\y > map_y-2 Then hero\y = map_y-2
     
      If maparray(hero\x,hero\y+1,3) = 0
         hero\y = hero\y + 1
         If Not hero\y > map_y-1
            map_scrolly = map_scrolly + TSIZE
         EndIf
         
      EndIf
   
   ElseIf KeyDown(KEY_LEFT) ;....................................... LINKS
      direction = LINKS
      If hero\x < 1 Then hero\x = 1
     
      If maparray(hero\x-1,hero\y,3) = 0
         hero\x = hero\x - 1
         If Not hero\x < 1
            map_scrollx = map_scrollx - TSIZE
         EndIf
         
      EndIf
     
   ElseIf KeyDown(KEY_RIGHT) ;....................................... RECHTS
      direction = RECHTS
      If hero\x > map_x-2 Then hero\x = map_x-2
     
      If maparray(hero\x+1,hero\y,3) = 0
         hero\x = hero\x + 1
         If Not hero\x > map_x-1
            map_scrollx = map_scrollx + TSIZE
         EndIf
         
      EndIf
  End If
   
End Function


Bei der Unten-Abfrage hab ich eine 2 in eine 1 verwandelt (ebenso bei der Rechts-Abfrage)
Code: [AUSKLAPPEN]
If Not hero\y > map_y-2


Aber wo ist das Problem?
os: Windows 10 Home cpu: Intel Core i7 6700K 4.00Ghz gpu: NVIDIA GeForce GTX 1080

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group