Farbwerte in Integers speichern, wo ist der Fehler?
Übersicht

E. Urbachehemals "Basicprogger"Betreff: Farbwerte in Integers speichern, wo ist der Fehler? |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Bitte sagt mir, dass der Code falsch ist:
BMax Code: [AUSKLAPPEN] 'Header
SuperStrict 'Init Graphics 640, 480, 0, 75 'Vars Global rot:Int = CreateRGBColor(255,0,0) Print rot Print Bin(rot) Print Hex(rot) 'Mainloop While KeyDown(KEY_ESCAPE)=0 And AppTerminate()=0 Cls SetRGBColor(rot) DrawText "Test1", 5, 5 SetRGBColor2(rot) DrawText "Test2", 5, 25 SetColor 255,0,0 DrawText "Test3", 5, 45 Flip Wend 'CreateRGBColor Function CreateRGBColor:Int(r:Byte, g:Byte, b:Byte) Return (r Shl 16) + (g Shl 8) + b End Function 'SetRGBColor Function SetRGBColor(rgb:Int) SetColor (rgb Shr 16) And 255, (rgb Shr 8) And 255, rgb And 255 End Function 'SetRGBColor2 Function SetRGBColor2(rgb:Int) SetColor (rgb And $00FF0000) / $10000, (rgb And $0000FF00) / $100, rgb And $000000FF End Function Bei mir wird nur "Test3" rot angezeigt. Die Funktion CreateRGBColor(r,g,b) packt die 3 Bytes in einen Integer. Die Funktion SetRGBColor bzw. SetRGBColor2 setzt die aktuelle Farbe durch SetColor. Das kann doch kein BMax Bug sein. In B3D funktioniert die Funktion: B3D Code: [AUSKLAPPEN] ;Init
Graphics 640, 480, 32, 2 ;Vars Global rot% = CreateRGBColor(255,0,0) Print rot Print Bin(rot) Print Hex(rot) ;Mainloop While KeyDown(1)=0 Cls SetRGBColor(rot) Text 5, 5, "Test1" SetRGBColor2(rot) Text 5, 25, "Test2" Color 255,0,0 Text 5, 45, "Test3" Flip Wend ;CreateRGBColor Function CreateRGBColor%(r, g, b) Return (r Shl 16) + (g Shl 8) + b End Function ;SetRGBColor Function SetRGBColor(rgb%) Color (rgb Shr 16) And 255, (rgb Shr 8) And 255, rgb And 255 End Function ;SetRGBColor2 Function SetRGBColor2(rgb%) Color (rgb And $00FF0000) / $10000, (rgb And $0000FF00) / $100, rgb And $000000FF End Function Wo ist der Fehler? |
||
The box said, "Requires Windows XP or better", so I installed Ubuntu | Linux is NOT Windows
Flua :: Profiler für BB und BMax :: Partikel-Engine für BMax :: Lyphia-Projekt Quellcode (BMax) :: Automatische Parallelisierung :: Meine Musik |
![]() |
FOODy |
![]() Antworten mit Zitat ![]() |
---|---|---|
In BlitzMax ist das Bitwise-And ein & und kein "And". | ||
BlitzMax + MaxGUI, 64-bit Arch Linux: Intel Core² E8500 | 8 GB Ram | GeForce GTX 460 · 1024 MB |
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Nicht nur das And ist anders:
And -> & Or -> | XOr(Im Normalen sprachraum nichtmehr vorhanden) -> ~ |
||
E. Urbachehemals "Basicprogger" |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ok, habs inzwischen selbst bemerkt, war aber etwas verwirrend, weil der Blitz3D-Code ja funktionierte.
Und in der Dokumentation hat mich dieses "binary" verwirrt: Zitat: Conditional 'And' binary operator.
Ich hätte mich wirklich besser informieren sollen... |
||
The box said, "Requires Windows XP or better", so I installed Ubuntu | Linux is NOT Windows
Flua :: Profiler für BB und BMax :: Partikel-Engine für BMax :: Lyphia-Projekt Quellcode (BMax) :: Automatische Parallelisierung :: Meine Musik |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group