Tilemap mit Smoothscrolling

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Vertex

Betreff: Tilemap mit Smoothscrolling

BeitragMi, Apr 07, 2004 21:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi!
Ja kann man nicht viel zu sagen, außer das man natürlich die Tiles
via LoadAnimImage, und die Map aus einer Mapdatei laden sollte.
BlitzBasic: [AUSKLAPPEN]

; Setting title and graphicresolution
AppTitle "Tilemap - Example"
Graphics 640, 480, 32, 2

; Compute how many tiles can show
Const vCount = 640/16+1 ; vertical
Const hCount = 480/16+1 ; horizontal

; Creating the tileset including 4 tiles | size = 16 * 16 Pixel
tileSet = CreateImage(16, 16, 4)
SetBuffer ImageBuffer(tileSet, 0)
Color 255, 0, 0 : Rect 0, 0, 16, 16, 1
SetBuffer ImageBuffer(tileSet, 1)
Color 0, 255, 0 : Rect 0, 0, 16, 16, 1
SetBuffer ImageBuffer(tileSet, 2)
Color 0, 0, 255 : Rect 0, 0, 16, 16, 1
SetBuffer ImageBuffer(tileSet, 3)
Color 255, 255, 0 : Rect 0, 0, 16, 16, 1

; Activate pageflipping
SetBuffer BackBuffer()


; Creating the tilemap sized by 80 * 50 tiles
Const mapWidth =79
Const mapHeight=49
Dim tileMap(mapWidth, mapheight)
; Fill width random tiles
For x=0 To mapWidth
For y=0 To mapHeight
tileMap(x, y)=Rnd(3)
Next
Next

While Not KeyDown(1)
; Getting input
If KeyDown(203) Then xScroll=xScroll-1
If KeyDown(205) Then xScroll=xScroll+1
If KeyDown(200) Then yScroll=yScroll-1
If KeyDown(208) Then yScroll=yScroll+1

; Check ranges
If xScroll<0 Then xScroll=0
If yScroll<0 Then yScroll=0

If (xScroll/16)-(xScroll Mod 16)>0 Then
If xScroll>(mapWidth-vCount)*16 Then xScroll=(mapWidth-vCount)*16
Else
If xScroll>(mapWidth-vCount-1)*16 Then xScroll=(mapWidth-vCount-1)*16
EndIf

If (yScroll/16)-(yScroll Mod 16)>0 Then
If yScroll>(mapHeight-hCount)*16 Then yScroll=(mapHeight-hCount)*16
Else
If yScroll>(mapHeight-hCount-1)*16 Then yScroll=(mapHeight-hCount-1)*16
EndIf

; Compute the top left tile
xStart=xScroll / 16
yStart=yScroll / 16
; Compute offsets
xOffset=xScroll Mod 16
yOffset=yScroll Mod 16

; Render all tiles
If xOffset>0 Then
If yOffset>0 Then
For x=0 To vCount
For y=0 To hCount
DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart)
Next
Next
Else
For x=0 To vCount
For y=0 To hCount-1
DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart)
Next
Next
EndIf
Else
If yOffset>0 Then
For x=0 To vCount-1
For y=0 To hCount
DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart)
Next
Next
Else
For x=0 To vCount-1
For y=0 To hCount-1
DrawBlock tileSet, x*16-xOffset, y*16-yOffset, tileMap(x+xStart, y+yStart)
Next
Next
EndIf
EndIf

Flip ; Blitting back- to frontbuffer
Wend

End ; Good bye!

mfg olli
vertex.dreamfall.at | GitHub
 

Kekskiller

BeitragMi, Apr 07, 2004 21:33
Antworten mit Zitat
Benutzer-Profile anzeigen
Schon schön , aber für ei Rpg reicht es noch lange nicht ^_^
 

darkshadow

BeitragSa, Apr 10, 2004 0:09
Antworten mit Zitat
Benutzer-Profile anzeigen
Es soll ja auch nur das Tilemapping und das Scrolling dargestellt werden. Ein RPG musst du schon selber coden.. Nix hier mit copy&paste Codes.
 

Kekskiller

BeitragSa, Apr 10, 2004 18:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Och Mensch , das war doch auch nur ein Scherz.Ein Rpg habe ich sowieso
schon selber zum Pasten gebaut.Nur wird keiner das Copy durchführen können 8)

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group