Problem mit BLENDSCREEN

Previous topic - Next topic

zocker4

Ich habe ein Programm geschrieben mit dem man ein sprite (a.bmp) über den Bildschirm bewegen kann. Beim berühren des randes kommt man auf die nächste andersfarbige fläche (insgesamt 9 flächen) alles läuft gut doch auf den ebenen ganz rechts funktioniert es nicht: alle ebenen nehmen die farbe der ersten an wenn ich von unten die ebenen durchgehe, vo oben funktioniert alles. Ich habe alles probiert und keinen Fehler gefunden!!! Mein Code:

Code (glbasic) Select
main:

LET world = 5
LOADBMP "red.bmp"
//800 auf 600 pixel
LOADSPRITE "a.bmp",0
//sprite hat 80 auf 80 pixel
// 200 203 205 208
// rechts= 750 unten 540
WHILE TRUE
GOSUB Steuerung

SHOWSCREEN
WEND











// ------------------------------------------------------------- //
// -=#  STEUERUNG  #=-
// ------------------------------------------------------------- //
SUB Steuerung:



a= 360
b= 260

SPRITE 0, a,b
WHILE TRUE
//oben
IF KEY(200) = 1
b=b-2
SPRITE 0, a, b
ELSE
SPRITE 0, a, b
ENDIF
//links
IF KEY(203) = 1
a=a-2
SPRITE 0, a, b
ELSE
SPRITE 0, a, b
ENDIF
//rechts
IF KEY(205) = 1
a=a+2
SPRITE 0, a, b
ELSE
SPRITE 0, a, b
ENDIF
// unten
IF KEY(208) = 1
b=b+2
SPRITE 0, a, b
ELSE
SPRITE 0, a, b
ENDIF
PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
//etc.
SHOWSCREEN
welten:
IF b<2 AND world = 5
b=b+2
GOSUB worldyellow2
ENDIF
IF b>540 AND world = 2
b=b -2
GOSUB red5
ENDIF
IF a>740 AND world = 5
GOSUB blue6
ENDIF
IF a<0 AND world = 6
GOSUB redRIGHT5
ENDIF
IF a<0 AND world = 5
GOSUB lila4
ENDIF
IF a>740 AND world = 4
GOSUB redleft5
ENDIF
IF b>540 AND world = 5
GOSUB gruenup8
ENDIF
IF b<0 AND world = 8
GOSUB reddown5
ENDIF
IF b<0 AND world = 4
GOSUB orangedown1
ENDIF
IF a<0 AND world = 2
GOSUB orangeright1
ENDIF
IF a>740 AND world = 1
GOSUB yellowleft2
ENDIF
IF b >540 AND world = 1
GOSUB lilaup4
ENDIF
IF a>740 AND world = 7
GOSUB gruenlinks8
ENDIF
IF a<0 AND world = 8
GOSUB schwarzrechts7
ENDIF
IF b >540 AND world = 4
GOSUB schwarzUP7
ENDIF
IF b<0 AND world = 7
GOSUB liladown4
ENDIF
IF a>740 AND world = 2
GOSUB weisleft3
ENDIF
IF b<0 AND world = 6
GOSUB weisdown3
ENDIF
IF b>540 AND world = 3
GOSUB blueUP6
ENDIF
IF a<0 AND world = 3
GOSUB yellowright2
ENDIF
IF b>540 AND world = 6
GOSUB braunUP9
ENDIF
IF a>740 AND world = 8
GOSUB braunLEFT9
ENDIF
IF a<0 AND world = 9
GOSUB grunerechts8
ENDIF
IF b<0 AND world = 9
GOSUB blueDOWN6
ENDIF
WEND
ENDSUB // STEUERUNG






// ------------------------------------------------------------- //
// -=#  WORLDYELLOW  #=-
// ------------------------------------------------------------- //
SUB worldyellow2:

BLENDSCREEN "yellow.bmp"

b =b +535

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =2
ENDSUB // WORLDYELLOW







// ------------------------------------------------------------- //
// -=#  RED  #=-
// ------------------------------------------------------------- //
SUB red5:

BLENDSCREEN "red.bmp"
b= b-535
SPRITE 0,a,b

SHOWSCREEN

LET world = 5
ENDSUB // RED











// ------------------------------------------------------------- //
// -=#  BLUE  #=-
// ------------------------------------------------------------- //
SUB blue6:

BLENDSCREEN "blue.bmp"

a =a -740

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =6


ENDSUB // BLUE




// ------------------------------------------------------------- //
// -=#  REDRIGHT  #=-
// ------------------------------------------------------------- //
SUB redRIGHT5:

BLENDSCREEN "red.bmp"
a =a + 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 5


ENDSUB // REDRIGHT




// ------------------------------------------------------------- //
// -=#  LILA  #=-
// ------------------------------------------------------------- //
SUB lila4:

BLENDSCREEN "lila.bmp"

a =a +740

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =4


ENDSUB // LILA




// ------------------------------------------------------------- //
// -=#  REDLEFT  #=-
// ------------------------------------------------------------- //
SUB redleft5:

BLENDSCREEN "red.bmp"
a =a - 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 5


ENDSUB // REDLEFT







// ------------------------------------------------------------- //
// -=#  GRUEN  #=-
// ------------------------------------------------------------- //
SUB gruenup8:

BLENDSCREEN "gruen.bmp"

b = b - 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =8


ENDSUB // GRUEN




// ------------------------------------------------------------- //
// -=#  REDDOWN  #=-
// ------------------------------------------------------------- //
SUB reddown5:
BLENDSCREEN "red.bmp"
b =b + 540
SPRITE 0,a,b

SHOWSCREEN

LET world = 5


ENDSUB // REDDOWN





// ------------------------------------------------------------- //
// -=#  ORANGEdown  #=-
// ------------------------------------------------------------- //
SUB orangedown1:

BLENDSCREEN "orange.bmp"

b = b + 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =1



ENDSUB // ORANGE




// ------------------------------------------------------------- //
// -=#  ORANGERIGHT  #=-
// ------------------------------------------------------------- //
SUB orangeright1:

BLENDSCREEN "orange.bmp"

a = a + 740

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =1





ENDSUB // ORANGERIGHT






// ------------------------------------------------------------- //
// -=#  LILAUP  #=-
// ------------------------------------------------------------- //
SUB lilaup4:

BLENDSCREEN "lila.bmp"

b = b - 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =4


ENDSUB // LILAUP






// ------------------------------------------------------------- //
// -=#  YELLOWLEFT  #=-
// ------------------------------------------------------------- //
SUB yellowleft2:

BLENDSCREEN "yellow.bmp"
a =a - 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 2

ENDSUB // YELLOWLEFT




// ------------------------------------------------------------- //
// -=#  WEIS3  #=-
// ------------------------------------------------------------- //
SUB weisleft3:
BLENDSCREEN "weis.bmp"
a =a - 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 3



ENDSUB // WEIS3




// ------------------------------------------------------------- //
// -=#  YELLOWRIGHT2  #=-
// ------------------------------------------------------------- //
SUB yellowright2:

BLENDSCREEN "yellow.bmp"

a = a + 740

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =2




ENDSUB // YELLOWRIGHT2




// ------------------------------------------------------------- //
// -=#  GRUNERECHTS8  #=-
// ------------------------------------------------------------- //
SUB grunerechts8:

BLENDSCREEN "gruen.bmp"
a =a + 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 8



ENDSUB // GRUNERECHTS8




// ------------------------------------------------------------- //
// -=#  GRUENLINKS8  #=-
// ------------------------------------------------------------- //
SUB gruenlinks8:
BLENDSCREEN "gruen.bmp"
a =a - 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 8



ENDSUB // GRUENLINKS8




// ------------------------------------------------------------- //
// -=#  WEISUP3  #=-
// ------------------------------------------------------------- //
SUB weisdown3:

BLENDSCREEN "weiß.bmp"

b = b + 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =3



ENDSUB // WEISUP3




// ------------------------------------------------------------- //
// -=#  SCHWARZRECHTS7  #=-
// ------------------------------------------------------------- //
SUB schwarzrechts7:

BLENDSCREEN "schwarz.bmp"

a = a + 740

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =7



ENDSUB // SCHWARZRECHTS7




// ------------------------------------------------------------- //
// -=#  SCHWARZUP7  #=-
// ------------------------------------------------------------- //
SUB schwarzUP7:

BLENDSCREEN "schwarz.bmp"

b = b - 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =7



ENDSUB // SCHWARZUP7




// ------------------------------------------------------------- //
// -=#  LILADOWN4  #=-
// ------------------------------------------------------------- //
SUB liladown4:

BLENDSCREEN "lila.bmp"

b = b + 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world = 4


ENDSUB // LILADOWN4




// ------------------------------------------------------------- //
// -=#  BLUEUP6  #=-
// ------------------------------------------------------------- //
SUB blueUP6:

BLENDSCREEN "blue.bmp"

b = b - 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =6



ENDSUB // BLUEUP6





// ------------------------------------------------------------- //
// -=#  BRAUNLEFT9  #=-
// ------------------------------------------------------------- //
SUB braunLEFT9:
BLENDSCREEN "braun.bmp"
a =a - 740
SPRITE 0,a,b

SHOWSCREEN

LET world = 9


ENDSUB // BRAUNLEFT9




// ------------------------------------------------------------- //
// -=#  BRAUNUP9  #=-
// ------------------------------------------------------------- //
SUB braunUP9:

BLENDSCREEN "braun.bmp"

b = b - 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =9


ENDSUB // BRAUNUP9





// ------------------------------------------------------------- //
// -=#  BLUEDOWN6  #=-
// ------------------------------------------------------------- //
SUB blueDOWN6:
BLENDSCREEN "blau.bmp"

b = b + 540

SPRITE 0,a,b


PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
SHOWSCREEN
world =6


ENDSUB // BLUEDOWN6

Kitty Hello

Ich hab's mir nich tim Detail angesehen, aber ich glaube, Du willst eine Landkarte haben, auf der Du rum'läuftst, und wen nDu an den Rand stößt, soll er nachladen, oder?

Schau Dir mal den Code hier an: (copy+paste in Dein Projekt)
Code (glbasic) Select
LOADSPRITE "a.bmp",0
//sprite hat 80 auf 80 pixel
// 200 203 205 208
// rechts= 750 unten 540

GLOBAL screenx, screeny
GETSCREENSIZE screenx, screeny

a= screenx/2
b= screeny/2
world = 5

GOSUB changeworld

WHILE TRUE
GOSUB Steuerung
GOSUB welten

SPRITE 0, a, b
PRINT "a nach rechts" + a  ,100,100
PRINT "b nach unten " + b ,160,150
PRINT "aktuelle Welt: "+world, 100, 20
//etc.
SHOWSCREEN
WEND





// ------------------------------------------------------------- //
// -=#  STEUERUNG  #=-
// ------------------------------------------------------------- //
SUB Steuerung:
//oben
IF KEY(200) = 1 THEN b=b-2
// unten
IF KEY(208) = 1 THEN b=b+2
//links
IF KEY(203) = 1 THEN a=a-2
//rechts
IF KEY(205) = 1 THEN a=a+2
ENDSUB

SUB welten:
// Die Karte der Welten:
//  1 2 3
//  4 5 6
//  7 8 9

// -> links rechts = +-1
// -> rauf runter = +-3
// oberer Rand:  welt<0
// unterer Rand: welt>9
// linker Rand:  MOD(welt, 3)=0
// rechter Rand: MOD(welt, 3)=1


// oberer rand
IF b<0
newworld=world -3
IF newworld<1 // Rand
b=0
ELSE // next world
b=screeny-80
world=newworld
GOSUB changeworld
ENDIF
ENDIF

// unterer rand
IF b>screeny-80
newworld=world +3
IF newworld>9 // Rand
b=screeny-80
ELSE // next world
b=0
world=newworld
GOSUB changeworld
ENDIF
ENDIF


// linker rand
IF a<0
newworld=world -1
IF MOD(newworld,3)=0 // Rand
a=0
ELSE // next world
a=screenx-80
world=newworld
GOSUB changeworld
ENDIF
ENDIF

// rechter rand
IF a>screenx-80
newworld=world +1
IF MOD(newworld,3)=1 // Rand
a=screenx-80
ELSE // next world
a=0
world=newworld
GOSUB changeworld
ENDIF
ENDIF
ENDSUB


SUB changeworld:
DIM wld$[10]
// Die Karte der Welten:
// 1 2 3
// 4 5 6
// 7 8 9

// Bitte hier die maps eintragen!!
wld$[1] = "red.bmp"
wld$[2] = "gruen.bmp"
wld$[3] = "blue.bmp"
wld$[4] = "lila.bmp"
wld$[5] = "yellow.bmp"
wld$[6] = "kingkong.bmp"
wld$[7] = "kungfu.bmp"
wld$[8] = "joecool.bmp"
wld$[9] = "jamesbond.bmp"

BLENDSCREEN wld$[world]
ENDSUB
Der macht genau das. Du musst in "SUB changeworld" halt die richtigen Namen für die Maps eintragen. Nimm Dir mal eine Stunde Zeit zu verstehen, was ich alles mach'. Wenn wa unklar ist, bitte nochmal fragen.
Das ist eine (so meine ich ) verständliche, aber dennoch recht gut programmierte Lösung.

zocker4

ich hab inzwischen den fehler gefunden. trotzdem danke!