WritePixelFast funzt net; WritePixel aber schon

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

Devils Child

Betreff: WritePixelFast funzt net; WritePixel aber schon

BeitragFr, Jun 24, 2005 13:35
Antworten mit Zitat
Benutzer-Profile anzeigen
hi leutz!
ich hab hier folgenden code von blitzbase:
Code: [AUSKLAPPEN]
GRAPHICS 640,480,0,1
SETBUFFER BACKBUFFER()
DIM X(299), Y#(299), V#(299)
FOR i=0 TO 299
   X (i)=RND(0,639)
   Y#(i)=RND(0,479)
   V#(i)=RND(1,5)
NEXT
COLOR 0,0,0
WHILE KEYHIT(1)=0
   RECT 0,0,640,480
   LOCKBUFFER BACKBUFFER()
   FOR i=0 TO 299
      Y#(i)=Y#(i)+V#(i)
      IF Y#(i)>479 THEN X(i)=RAND(0,639):Y#(i)=Y#(i)-480:V#(i)=RND(1,5)
      Grau=INT(v#(i))*50
      Farbe=Grau*$10000+Grau*$100+Grau
      WRITEPIXELFAST x(i),y#(i),Farbe
   NEXT
   UNLOCKBUFFER BACKBUFFER()
   FLIP
WEND
END

wenn ich ihn starte ist die zeile, wo writeopixelfast steht "memory acces volation". wenn ich "writepixelfast" durch "writepixel" ersetze funktioiert das.
woran kann das nur liegen?
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Alfadur

BeitragFr, Jun 24, 2005 13:51
Antworten mit Zitat
Benutzer-Profile anzeigen
komischerweise funktioniert es wenn man graphics 640,480,0,2 macht, also im fenster startet... keinen plan woran es liegt. bei mir funktioniert es immer.... !?
A Cray is the only computer that runs an endless loop in less than four hours.

Devils Child

BeitragFr, Jun 24, 2005 13:57
Antworten mit Zitat
Benutzer-Profile anzeigen
bei mir auch, aber woran liegt das..?
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Mr.Keks

BeitragFr, Jun 24, 2005 14:01
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
GRAPHICS 640,480,0,1
SETBUFFER BACKBUFFER()
DIM X(299), Y#(299), V#(299)
FOR i=0 TO 299
   X (i)=RND(0,639)
   Y#(i)=RND(0,479)
   V#(i)=RND(1,5)
NEXT
COLOR 0,0,0
WHILE KEYHIT(1)=0
   RECT 0,0,640,480
   LOCKBUFFER BACKBUFFER()
   FOR i=0 TO 299
      Y#(i)=Y#(i)+V#(i)
      IF Y#(i)>479 THEN X(i)=RAND(0,639):[b]Y#(i)=1[/b]:V#(i)=RND(1,5)
      Grau=INT(v#(i))*50
      Farbe=Grau*$10000+Grau*$100+Grau
      WRITEPIXELFAST x(i),y#(i),Farbe
   NEXT
   UNLOCKBUFFER BACKBUFFER()
   FLIP
WEND
END
bin mir nicht ganz sicher, aber ich glaube, es hängt mit integer- und float-rundung zusammen:
y# = 479.4
blitzbasic beachtet das beim if, da es ein float ist. es ist also größer als 479. wenn man jetzt 480 abzieht, ist es kleiner als 0. bei writepixelfast wird auf integer gerundet. der entsprechende integer ist -1. und writepixelfast x,-1,rgb gibt nen error.
MrKeks.net

Alfadur

BeitragFr, Jun 24, 2005 14:08
Antworten mit Zitat
Benutzer-Profile anzeigen
dann müßte der aber auch im debugger kommen, der fehler ...

BlitzBasic: [AUSKLAPPEN]

Graphics 800,600
SetBuffer BackBuffer()

Type Tstar
Field x#
Field y#
Field speed#
End Type

Function create_stars(count)
For i=1 To count
star.Tstar=New Tstar
star\x#=Rand(799)
star\y#=Rand(600)
star\speed#=Rand(1,5)
Next
End Function

Function draw_stars()
LockBuffer BackBuffer()
For star.Tstar=Each Tstar
star\y#=star\y#+star\speed#
If star\y#>599 Then star\y#=star\y#-599
Farbe=Grau*$10000+Grau*$100+Grau
WritePixelFast star\x#,star\y#,star\speed#*50*$10000+star\speed#*50*$100+star\speed#*50
Next
UnlockBuffer BackBuffer()
End Function

create_stars(300)

While Not KeyHit(1)

Cls
draw_stars()
Flip 0

Wend

End


hab gerade mal code geschrieben. funzt... trotz writepixelfast Smile
A Cray is the only computer that runs an endless loop in less than four hours.

Mr.Keks

BeitragFr, Jun 24, 2005 14:11
Antworten mit Zitat
Benutzer-Profile anzeigen
Zitat:
If star\y#>599 Then star\y#=star\y#-599
hättest du da wie theshadow beim zweiten -600 geschrieben, gäbe es auch nen absturz.
MrKeks.net

Alfadur

BeitragFr, Jun 24, 2005 14:16
Antworten mit Zitat
Benutzer-Profile anzeigen
habs gerade 10 sek mit 30000 sternen laufen lassen und -600 statt -599, kommt trotzdem kein absturz. bei dem ersten prog kam der absturz ja immer gleich sofort ... ohne überhaupt irgendwas zu machen
A Cray is the only computer that runs an endless loop in less than four hours.

Devils Child

BeitragFr, Jun 24, 2005 14:26
Antworten mit Zitat
Benutzer-Profile anzeigen
hm? wenn er runden soll... wie soll ich es denn jetzt machen?
so ganz verstehe ich das immernochnicht.
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Rallimen

Sieger des 30-EUR-Wettbewerbs

BeitragFr, Jun 24, 2005 14:51
Antworten mit Zitat
Benutzer-Profile anzeigen
Machs doch mit
BlitzBasic: [AUSKLAPPEN]
y#(i)= y#(i) Mod 480 
WritePixelFast x(i), Floor y#(i),Col

Mit floor wird abgerundet, da es sonst passieren könnte das du bei y#(i)= 479.6 (=480) ausserhalb des Buffers schreibst!
dann gibt es das Problem mit Writepixelfast nicht!
Mit Mod bekommst du nie einen negativen Wert und ganau das macht was du eigendlich vorhattest!
[BB2D | BB3D | BB+]

Devils Child

BeitragFr, Jun 24, 2005 15:06
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]

Graphics 640,480,0,1
SetBuffer BackBuffer()
Dim X(299), Y#(299), V#(299)
For i=0 To 299
   X (i)=Rnd(0,639)
   Y#(i)=Rnd(0,479)
   V#(i)=Rnd(1,5)
Next
Color 0,0,0
While KeyHit(1)=0
   Rect 0,0,640,480
   LockBuffer BackBuffer()
   For i=0 To 299
      Y#(i)=Y#(i)+V#(i)
      If Y#(i)>479 Then X(i)=Rand(0,639):Y#(i)=Y#(i)-480:V#(i)=Rnd(1,5)
      Grau=Int(v#(i))*50
      Farbe=Grau*$10000+Grau*$100+Grau
y#(i)= y#(i) Mod 480
WritePixelFast x(i), Floor(y#(i)),Farbe
   Next
   UnlockBuffer BackBuffer()
   Flip
Wend
End

ehm...immernoch?!
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Mr.Keks

BeitragFr, Jun 24, 2005 15:09
Antworten mit Zitat
Benutzer-Profile anzeigen
mach doch einfach y(i)=1 und dann is gut ^^.
MrKeks.net

Rallimen

Sieger des 30-EUR-Wettbewerbs

BeitragFr, Jun 24, 2005 15:13
Antworten mit Zitat
Benutzer-Profile anzeigen
Ist auch klar, weil du in den negativen Bereich reinkommst
du mußt auch dann mit Mod arbeiten!
x# = -0.3
Floor (x#) = -1

BlitzBasic: [AUSKLAPPEN]
Graphics 640 ,480,0,1
SetBuffer BackBuffer ()
Dim X (299) , Y# (299) , V# (299)
For i = 0 To 299
X (i) = Rnd (0 ,639)
Y# (i) = Rnd (0 ,479)
V# (i) = Rnd (1 ,5)
Next
Color 0 ,0,0

While KeyHit (1) = 0
Rect 0 ,0,640,480
LockBuffer BackBuffer ()
For i = 0 To 299
Y# (i) = Y# (i) + V# (i)
If Y# (i) > 479 Then X (i) = Rand (0 ,639) : Y# (i) = Y# (i) Mod 480 : V# (i) = Rnd (1 ,5)
Grau = Int (v# (i) ) * 50
Farbe = Grau * $10000 + Grau * $100 + Grau
y# (i) = y# (i) Mod 480
WritePixelFast x (i) , Floor (y# (i) ) ,Farbe
Next
UnlockBuffer BackBuffer ()
Flip
Wend

End
[BB2D | BB3D | BB+]

maximilian

BeitragFr, Jun 24, 2005 15:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Windows kontrolliert soweit ich weiß Anwendungen, die im Fenster laufen. Deswegen sind diese auch deutlich langsamer, als im Vollbild.

LordChaos
Variety is the spice of life. One day ignore people, next day annoy them.

Spikespine

BeitragFr, Jun 24, 2005 15:36
Antworten mit Zitat
Benutzer-Profile anzeigen
Zitat:
und writepixelfast x,-1,rgb gibt nen error.


Liegt das am PC? Denn folgender Code:


BlitzBasic: [AUSKLAPPEN]
Graphics 640,480,0,2
SetBuffer BackBuffer()
LockBuffer BackBuffer()
WritePixelFast -1,100,$FFFFFF
UnlockBuffer BackBuffer()
Flip
WaitKey
End


zeichnet bei mir ohne Fehlermeldung einen Punkt auf der Koordinate 639,480.

Spike
Athlon 64 3700+ | 1024 MB RAM | GeForce 7900 GT | Blitz2D, Blitz3D, BlitzPlus, BlitzMax

Rallimen

Sieger des 30-EUR-Wettbewerbs

BeitragFr, Jun 24, 2005 15:41
Antworten mit Zitat
Benutzer-Profile anzeigen
Du machst das im Fenstermodus, da geht es weil Windows das übernimmt!

Gehts denn mit Graphics 640,480,0,1 auch?
[BB2D | BB3D | BB+]

Devils Child

BeitragFr, Jun 24, 2005 15:49
Antworten mit Zitat
Benutzer-Profile anzeigen
gut, ich habe hier folgendes programm...und wie soll ich jetzt writepixeldfast einbauen?
Code: [AUSKLAPPEN]
Graphics 800, 600, 32, 1
SetBuffer BackBuffer()

;Types
Type Bomb
  Field x#, y#, xs#, ys#, time#
End Type
Type Explosion
  Field x#, y#, xs#, ys#, col#[3]
End Type

While Not KeyHit(1) Or MouseXSpeed() < -3 Or MouseYSpeed() < -3
  Cls
  LockBuffer()
  If Rand(1, 10) = 5 Then AddBomb()
  UpdateExplosions()
  UpdateBombs()
  UnlockBuffer()
  Flip
Wend
End

Function AddBomb()
b.Bomb = New Bomb
b\x# = Rand(1, GraphicsWidth())
b\x# = Rand(10, GraphicsWidth() - 10)
b\y# = GraphicsHeight()
b\xs# = Rand(-100, 100)
b\ys# = Rand(-250, -300)
End Function

Function UpdateBombs()
For b.Bomb = Each Bomb
  b\time# = b\time# + 1
  Rectangle(b\x#, b\y#)
  b\x# = b\x# + b\xs# / 30
  b\y# = b\y# + b\ys# / 30
  b\ys# = b\ys# + 3
  If b\x# < 0 Or b\x# > GraphicsWidth() Then b\xs# = -b\xs#
  If b\time# > 100 Then
    For i = 1 To 500
      AddExplosion(b\x#, b\y#)
    Next
    Delete b
  EndIf
Next
End Function

Function UpdateExplosions()
For e.Explosion = Each Explosion
  e\x# = e\x# + e\xs# / 100
  e\y# = e\y# + e\ys# / 100
  e\ys# = e\ys# + 10
  ;WritePixel e\x#, e\y#, e\col#[1] * $10000 + e\col#[2] * $100 + e\col#[3]
  WritePixelFast Floor(e\x#), Floor(e\y#), e\col#[1] * $10000 + e\col#[2] * $100 + e\col#[3]
  For i = 1 To 3
    e\col#[i] = e\col#[i] - 2
    If e\col#[i] < 0 Then e\col#[i] = 0
  Next
  If e\col#[1] < 1 And e\col#[2] < 1 And e\col#[3] < 1 Or e\y# > GraphicsHeight() Or e\x# < 0 Or e\x# > GraphicsWidth() Then Delete e
Next
End Function

Function AddExplosion(x#, y#)
e.Explosion = New Explosion
e\x# = x#
e\y# = y#
e\xs# = Tan(Rand(-1000, 1000)) * 60
e\ys# = Tan(Rand(-1000, 1000)) * 60
For i = 1 To 3
  e\col#[i] = Rand(100, 255)
Next
End Function

Function Rectangle(x1, y1)
For x = -2 To 2
  For y = -2 To 2
    WritePixelFast x1 + x, y1 + y, 16777215
  Next
Next
End Function
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Spikespine

BeitragFr, Jun 24, 2005 15:57
Antworten mit Zitat
Benutzer-Profile anzeigen
Rallimen hat Folgendes geschrieben:
Du machst das im Fenstermodus, da geht es weil Windows das übernimmt!

Gehts denn mit Graphics 640,480,0,1 auch?


Jo, gibt keine Fehlermeldung.
aber der Punkt wird nicht gezeichnet, anders als im Fenstermodus.

Spike
Athlon 64 3700+ | 1024 MB RAM | GeForce 7900 GT | Blitz2D, Blitz3D, BlitzPlus, BlitzMax

Devils Child

BeitragFr, Jun 24, 2005 16:03
Antworten mit Zitat
Benutzer-Profile anzeigen
doch, es gibt ne fehlermeldung, und im fenstermodus auch. kann mir mal jemand das so umproggen, dass es funtzt Question Very Happy
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Rallimen

Sieger des 30-EUR-Wettbewerbs

BeitragFr, Jun 24, 2005 16:22
Antworten mit Zitat
Benutzer-Profile anzeigen
hab ich mal ein paar Sicherungen eingebaut, damit es schon mal geht!
Ist aber nicht die 1.Wahl!

BlitzBasic: [AUSKLAPPEN]
Graphics 800, 600, 32, 1 
SetBuffer BackBuffer()

;Types
Type Bomb
Field x#, y#, xs#, ys#, time#
End Type
Type Explosion
Field x#, y#, xs#, ys#, col#[3]
End Type

While Not KeyHit(1) Or MouseXSpeed() < -3 Or MouseYSpeed() < -3
Cls
LockBuffer()
If Rand(1, 10) = 5 Then AddBomb()
UpdateExplosions()
UpdateBombs()
UnlockBuffer()
Flip
Wend
End

Function AddBomb()
b.Bomb = New Bomb
b\x# = Rand(1, GraphicsWidth())
b\x# = Rand(10, GraphicsWidth() - 10)
b\y# = GraphicsHeight()
b\xs# = Rand(-100, 100)
b\ys# = Rand(-250, -300)
End Function

Function UpdateBombs()
For b.Bomb = Each Bomb
b\time# = b\time# + 1
Rectangle(b\x#, b\y#)
b\x# = b\x# + b\xs# / 30
b\y# = b\y# + b\ys# / 30
b\ys# = b\ys# + 3
If b\x# < 0 Or b\x# > GraphicsWidth() Then b\xs# = -b\xs#
If b\time# > 100 Then
For i = 1 To 500
AddExplosion(b\x#, b\y#)
Next
Delete b
EndIf
Next
End Function

Function UpdateExplosions()
For e.Explosion = Each Explosion
e\x# = e\x# + e\xs# / 100
e\y# = e\y# + e\ys# / 100
e\ys# = e\ys# + 10
;WritePixel e\x#, e\y#, e\col#[1] * $10000 + e\col#[2] * $100 + e\col#[3]
If Floor(e\x#)> 0 And Floor(e\x#)< GraphicsWidth()
If Floor(e\y#)> 0 And Floor(e\y#)< GraphicsHeight()
WritePixelFast Floor(e\x#), Floor(e\y#), e\col#[1] * $10000 + e\col#[2] * $100 + e\col#[3]
End If
End If
For i = 1 To 3
e\col#[i] = e\col#[i] - 2
If e\col#[i] < 0 Then e\col#[i] = 0
Next
If e\col#[1] < 1 And e\col#[2] < 1 And e\col#[3] < 1 Or e\y# > GraphicsHeight() Or e\x# < 0 Or e\x# > GraphicsWidth() Then Delete e
Next
End Function

Function AddExplosion(x#, y#)
e.Explosion = New Explosion
e\x# = x#
e\y# = y#
e\xs# = Tan(Rand(-1000, 1000)) * 60
e\ys# = Tan(Rand(-1000, 1000)) * 60
For i = 1 To 3
e\col#[i] = Rand(100, 255)
Next
End Function

Function Rectangle(x1, y1)
For x = -2 To 2
For y = -2 To 2
If x1 + x >0 And x1 + x < GraphicsWidth()
If y1 + y>0 And y1 + y < GraphicsHeight()
WritePixelFast x1 + x, y1 + y, 16777215
End If
End If
Next
Next
End Function
[BB2D | BB3D | BB+]

Devils Child

BeitragFr, Jun 24, 2005 16:26
Antworten mit Zitat
Benutzer-Profile anzeigen
oh, cool jetzt gehts.
THX@ALL Very Happy
*X-Ware Member*

Mission to Hell[Ego-Shooter]
Hier Vollversion runterladen:
http://patrick-sch.de/spiele/m...ersion.zip

ich antworte auf jede PN

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group