Map Problem

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

Mathias-Kwiatkowski

Betreff: Map Problem

BeitragSa, Sep 22, 2007 23:52
Antworten mit Zitat
Benutzer-Profile anzeigen
hi leute warum wird meine map nicht richtig angezeigt?

CODE:
Code: [AUSKLAPPEN]
Graphics 800,600,32

Cam_X=400-16
Cam_Y=300-16

Player_X=800
Player_Y=800

Dim Map(5000,5000)

Map(1000,700)=1
Map(900,900)=1

Repeat
   Cls
   Color 255,255,0

   For x=Player_X-Cam_X To Player_X-Cam_X +800
      For y=Player_Y-Cam_Y To Player_Y-Cam_Y +600
         If Map(x,y)=1 Then Plot x,y
      Next
   Next

   
   Color 255,0,0
   Rect Cam_X,Cam_Y,32,32


   
   Color 255,255,255
   Text 10,10,"Mouse X:"+MouseX()
   Text 10,20,"Mouse Y:"+MouseY()
   Text 10,30,"Player X:"+Player_X
   Text 10,40,"Player Y:"+Player_y
   
   Line MouseX(),MouseY(),MouseX()+10,MouseY()
   Line MouseX(),MouseY(),MouseX(),MouseY()+10
   Line MouseX(),MouseY(),MouseX()+15,MouseY()+15

   If MouseDown(1) Then
      If MouseX()>Cam_X Then Player_X=Player_X+1
      If MouseX()<Cam_X Then Player_X=Player_X-1
      If MouseY()>Cam_Y Then Player_Y=Player_Y+1
      If MouseY()<Cam_Y Then Player_Y=Player_Y-1
   EndIf
   

   If Player_X<0+Cam_X Then Player_X=0+Cam_X
   If Player_Y<0+Cam_Y Then Player_Y=0+Cam_Y

   If Player_X>5000-Cam_X Then Player_X=5000-Cam_X
   If Player_Y>5000-Cam_Y Then Player_Y=5000-Cam_Y
   
   If MouseDown(2) Then End
   Flip
Forever

hectic

Sieger des IS Talentwettbewerb 2006

BeitragSo, Sep 23, 2007 0:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Du gehst die Dim-Abfrage etwas falsch an. Ausserdem würde ich es generell vermeiden 20mal MouseX() oder MouseY() abzurufen. Lieber den Wert zwischenspeichern.

Hier mal ein Beispiel:

Code: [AUSKLAPPEN]
Graphics 800,600,0,2
SetBuffer BackBuffer()

Cam_X=400-16
Cam_Y=300-16

Player_X=800
Player_Y=800

Dim Map(5000,5000)

For q=0 To 99999
   Map(Rand(0,5000),Rand(0,5000))=1   
Next




Repeat
   Cls
   Color 255,255,0
   
   mx=MouseX()
   my=MouseY()
   
   For x=0 To 79
      For y=0 To 59
         If Map(x+Player_X-Cam_X,y+Player_Y-Cam_Y)=1 Then Rect x*10,y*10,10,10,1
      Next
   Next
   
   Color 255,255,255
   Text 10,10,"Mouse X:"+mx
   Text 10,20,"Mouse Y:"+my
   Text 10,30,"Player X:"+Player_X
   Text 10,40,"Player Y:"+Player_y
   
   Line mx,my,mx+10,my
   Line mx,my,mx,my+10
   Line mx,my,mx+15,my+15
   
   If MouseDown(1) Then
      If mx>Cam_X Then Player_X=Player_X+1
      If mx<Cam_X Then Player_X=Player_X-1
      If my>Cam_Y Then Player_Y=Player_Y+1
      If my<Cam_Y Then Player_Y=Player_Y-1
   EndIf
   
   
   If Player_X<0+Cam_X Then Player_X=0+Cam_X
   If Player_Y<0+Cam_Y Then Player_Y=0+Cam_Y
   
   If Player_X>5000-Cam_X Then Player_X=5000-Cam_X
   If Player_Y>5000-Cam_Y Then Player_Y=5000-Cam_Y
   
   If MouseDown(2) Then End
   Flip
Forever
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group