Möchte grosses map machen aber wie mache ich scrolling ?

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

dimaster

Betreff: Möchte grosses map machen aber wie mache ich scrolling ?

BeitragMo, Apr 19, 2004 20:51
Antworten mit Zitat
Benutzer-Profile anzeigen
Also ich möchte ein grosses map machen.Aber wie mache ich scrolling im mapeditor?Wie würdet ihr das scrolling in diesen kleinen editior einbauen?
Code: [AUSKLAPPEN]

Dim map(39,31)
Graphics 1280,1024,16,1
Tileset = LoadAnimImage("gfx/tileset2.bmp",32,32,0,45)
Maus = LoadImage("gfx/maus.bmp")
Global x,y,mx,my,mapx,mapy,tile = 1
Repeat
Cls
SetBuffer BackBuffer()
If KeyDown(1) Then End
For x = 0 To 39
For y = 0 To 31
DrawImage tileset,x*32,y*32,map(x,y)
Next
Next
If KeyDown(2) Then tile = 1
If KeyDown(3) Then tile = 2
If KeyDown(4) Then tile = 3
If KeyDown(5) Then tile = 4
If KeyDown(6) Then tile = 5
If KeyDown(7) Then tile = 6
If KeyDown(8) Then tile = 7
If KeyDown(9) Then tile = 8
If KeyDown(10) Then tile = 9
If KeyDown(11) Then tile = 10
If KeyDown(12) Then tile = 11
If KeyDown(13) Then tile = 12
If KeyDown(14) Then tile = 13
If KeyDown(15) Then tile = 14
If KeyDown(16) Then tile = 15
If KeyDown(17) Then tile = 16
If KeyDown(18) Then tile = 17
If KeyDown(19) Then tile = 18
If KeyDown(20) Then tile = 19
If KeyDown(21) Then tile = 20
If KeyDown(22) Then tile = 21
If KeyDown(23) Then tile = 22
If KeyDown(24) Then tile = 23
If KeyDown(25) Then tile = 24
If KeyDown(26) Then tile = 25
If KeyDown(27) Then tile = 26
If KeyDown(28) Then tile = 27
If KeyDown(29) Then tile = 28
If KeyDown(30) Then tile = 29
If KeyDown(32) Then tile = 30
If KeyDown(33) Then tile = 31
If KeyDown(34) Then tile = 32
If KeyDown(35) Then tile = 33
If KeyDown(36) Then tile = 34
If KeyDown(37) Then tile = 35
If KeyDown(39) Then tile = 36
If KeyDown(40) Then tile = 37
If KeyDown(41) Then tile = 38

mx = MouseX()
my = MouseY()
If MouseDown(1) Then
scroll()
map(mapx,mapy) = tile
End If

If MouseDown(2) Then
scroll()
map(mapx,mapy) = 0
End If

If KeyHit(31) Then save()
If KeyHit(38) Then load()
DrawImage maus,mx,my
Flip
Forever

Function scroll()
mapx = (mx)/32
mapy = (my)/32
End Function
Function save()
karte$ = WriteFile("map1.map")
For x = 0 To 39
For y = 0 To 31
WriteLine(karte$,tile)
WriteInt(karte$,map(x,y))
Next
Next
CloseFile(karte$)
End Function
Function load()
karte$ = ReadFile("map1.map")
For x = 0 To 39
For y = 0 To 31
tile = ReadLine(karte$)
map(x,y) = ReadInt(karte$)
Next
Next
CloseFile(karte$)
End Function

Question Question Question Question

Freeman

BeitragMo, Apr 19, 2004 21:04
Antworten mit Zitat
Benutzer-Profile anzeigen
du musst bei deiner Tastenabfrage für oben ,unten, links und rechts ne Variable einfügen die die X / y position der Karte ändert , auf deinen Code bezogen (obwohl ich da nich durchseh ) :

Code: [AUSKLAPPEN]

drawimage tileset, (x*32) - scrollX , (y*32) - scrolly,Map(x,y)


natürlich musst du bei deiner Tastenabfrage noch die genaue größe der Variablen scrollX und scrollY festlegen.

Freeman
MacBook | MacOSX 10.5 | 80GB HDD | 1GB | BlitzMax 1.28

dimaster

BeitragMo, Apr 19, 2004 21:08
Antworten mit Zitat
Benutzer-Profile anzeigen
ja das habe ic auch schon versucht aber es gibt da son Problem mit der maus!!Sie malt dann wo anders(SIE SCROLLT NICHT MITT!!!)

Freeman

BeitragMo, Apr 19, 2004 21:12
Antworten mit Zitat
Benutzer-Profile anzeigen
na dann musst du die scrollx und scrolly auch bei den MausX und MausY Variablen abziehn.
MacBook | MacOSX 10.5 | 80GB HDD | 1GB | BlitzMax 1.28

Michi1988

BeitragMo, Apr 19, 2004 21:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Also erst ma.
Findest du nich das das mit den Zahlentasten vollkommen überflüssig und übertrieben ist? Würde einfach nur in einer Ecka das im Mom benutze Teil anzeigen lassen und wenn man auf Plus drückt, geht das nächste Teil an die Position.

du musst, wenn du den Kram malen lässt, auch in der Abfrage diese Koordinaten einfügen.

dimaster

BeitragMo, Apr 19, 2004 21:19
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]

Dim map(39,31)
Graphics 1280,1024,16,1
Tileset = LoadAnimImage("gfx/tileset2.bmp",32,32,0,45)
Maus = LoadImage("gfx/maus.bmp")
Global x,y,mx,my,mapx,mapy,tile = 1
Repeat
Cls
SetBuffer BackBuffer()
If KeyDown(1) Then End
For x = 0 To 39
For y = 0 To 31
DrawImage tileset,x*32-scrollx,y*32-scrolly,map(x,y)
Next
Next
If KeyDown(28) Then tile = tile +1 
If KeyDown(57) Then tile = tile -1

mx = MouseX()
my = MouseY()
If MouseDown(1) Then
scroll()
map(mapx,mapy) = tile
End If

If MouseDown(2) Then
scroll()
map(mapx,mapy) = 0
End If

If KeyHit(31) Then save()
If KeyHit(38) Then load()
if keydown(208) then   scrolly = scrolly + 32
if keydown(200) then   scrolly = scrolly - 32
if keydown(203) then   scrollx = scrollx + 32
if keydown(205) then   scrollx = scrollx - 32

DrawImage maus,mx*32-scrollx,my*32-scrolly
Flip
Forever

Function scroll()
mapx = (mx)/32
mapy = (my)/32
End Function
Function save()
karte$ = WriteFile("map1.map")
For x = 0 To 39
For y = 0 To 31
WriteLine(karte$,tile)
WriteInt(karte$,map(x,y))
Next
Next
CloseFile(karte$)
End Function
Function load()
karte$ = ReadFile("map1.map")
For x = 0 To 39
For y = 0 To 31
tile = ReadLine(karte$)
map(x,y) = ReadInt(karte$)
Next
Next
CloseFile(karte$)
End Function

So gets nicht Exclamation
Wie würdest du es machen Question

Michi1988

BeitragDi, Apr 20, 2004 13:56
Antworten mit Zitat
Benutzer-Profile anzeigen
*gähn*

Code: [AUSKLAPPEN]

Dim map(39,31)
Graphics 800,600,16,2
Tileset = LoadAnimImage("gfx/tileset2.bmp",32,32,0,45)
Maus = LoadImage("gfx/maus.bmp")

For x = 0 To 39
For y = 0 To 31
   map(x,y)=Rnd(40)
Next
Next

SetBuffer BackBuffer()
   Repeat
   If KeyDown(1) Then End

   For x = 0 To 39
   For y = 0 To 31
      DrawImage tileset,x*32-scrollx,y*32-scrolly,map(x,y)
   Next
   Next

   If KeyDown(28) Then tile = tile +1
   If KeyDown(57) Then tile = tile -1

   If MouseHit(1) Then
      For x = 0 To 39
      For y = 0 To 31
         map((MouseX()/32),(MouseY()/32)) = tile
      Next
      Next
   End If

   If KeyHit(208) Then scrolly = scrolly + 32
   If KeyHit(200) Then scrolly = scrolly - 32
   If KeyHit(205) Then scrollx = scrollx + 32
   If KeyHit(203) Then scrollx = scrollx - 32

   DrawImage maus,MouseX(),MouseY()

   Flip
   Cls
Forever

dimaster

BeitragDi, Apr 20, 2004 19:11
Antworten mit Zitat
Benutzer-Profile anzeigen
geht nett die maus malt immer woanders so hatte ichs auch scho Question

Michi1988

BeitragDi, Apr 20, 2004 19:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]

Dim map(39,31)
Graphics 800,600,16,2
Tileset = LoadAnimImage("gfx/tileset2.bmp",32,32,0,45)
Maus = LoadImage("gfx/maus.bmp")

For x = 0 To 39
For y = 0 To 31
   map(x,y)=Rnd(40)
Next
Next

SetBuffer BackBuffer()
   Repeat
   If KeyDown(1) Then End

   For x = 0 To 39
   For y = 0 To 31
      DrawImage tileset,x*32-scrollx,y*32-scrolly,map(x,y)
   Next
   Next

   If KeyDown(28) Then tile = tile +1
   If KeyDown(57) Then tile = tile -1

   If MouseHit(1) Then
      For x = 0 To 39
      For y = 0 To 31
         If RectsOverlap(x*32-scrollx,y*32-scrolly,32,32,MouseX(),MouseY(),1,1) Then
            map(x,y)=tile
         End If
      Next
      Next
   End If

   If KeyHit(208) Then scrolly = scrolly + 32
   If KeyHit(200) Then scrolly = scrolly - 32
   If KeyHit(205) Then scrollx = scrollx + 32
   If KeyHit(203) Then scrollx = scrollx - 32

   DrawImage maus,MouseX(),MouseY()

   Flip
   Cls
Forever

dimaster

BeitragDi, Apr 20, 2004 20:22
Antworten mit Zitat
Benutzer-Profile anzeigen
ah jetz gets!! Danke
 

dubitat

BeitragDi, Apr 20, 2004 21:12
Antworten mit Zitat
Benutzer-Profile anzeigen
einfach mousex() und mouseY() neu setzen...
Erare humanum est - Irren ist Menschlich

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group