Animationseditor mit pseudotiefe

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

hitokiri

Betreff: Animationseditor mit pseudotiefe

BeitragSa, Mai 07, 2005 23:34
Antworten mit Zitat
Benutzer-Profile anzeigen
Hoi, schreibe gerade an einem Animationseditor und da er noch nich fertig ist und auch kein Spiel dachte ich, dass ich ihn wohl eher hier reinstelle als in Projekte.
Es fehlen noch eine Menge abfragen hinsichtlich File vorhanden etc. und das GUI ist auch noch nicht vorhanden, die GOTO sind allerdings absicht (!).
Ich habe readpixelfast und writepixelfast weil ich gerade an einem abdunkeln arbeite wenn man es in die Tiefe des Raums verschwinden lässt und Plane, sofern ich die Mathe kapiere, es zu ermöglichen das bild zu verzerren, also nen reinen textur 3d animator und bearbeiter. hier erstmal der Code:
BlitzBasic: [AUSKLAPPEN]



Graphics 800,600

Global framecount[1000]
.start
Cls
Global filehandle$=Input$(\"Full path and filename of image to be loaded: \")
Global image=LoadImage(filehandle$)
Global imagew=ImageWidth(image)
Global imageh=ImageHeight(image)
If imagew>640 Or imageh>480
Print \"Image is too big!!\"
Print \"Maximum size is 640x480\"
Goto start
EndIf

; Initialise an array big enough to fit all the color information of the screen
Dim pix(imagew,imageh)

SetBuffer ImageBuffer(image)
LockBuffer ImageBuffer


For y=0 To imageh-1
For x=0 To imagew-1
pix(x,y)=ReadPixelFast(x,y)
Next
Next

; Lock buffer after using ReadPixelFast
UnlockBuffer ImageBuffer

SetBuffer BackBuffer()

.moron
Cls
Global xblubb%=Input$(\"give x coordinate for the image\")
If xblubb <0 Or xblubb >800-imagew Then Goto moron
.moron2
Global yblubb%=Input$(\"give y coordinate for the image\")
If yblubb <0 Or yblubb >500-imageh Then Goto moron2



WaitKey()
FlushKeys()


LockBuffer BackBuffer()
For x= 0 To imagew-1
For y= 0 To imageh-1
WritePixelFast xblubb+x,yblubb+y,pix(x,y)
Next
Next
UnlockBuffer BackBuffer()
Flip

WaitKey()
FlushKeys()
Cls
.moron3
xstart%=Input$(\"Input x position at start: \")
If xstart+imagew>800 Then Goto moron3
xend%=Input$(\"input x position at end: \")
If xend+imagew>800 Then Goto moron3
ystart%=Input$(\"input y position at start: \")
If ystart+imageh>600 Then Goto moron3
yend%=Input$(\"input y position at end: \")
If yend+imageh>600 Then Goto moron3
scalestart#=Input$(\"input size at start (syntax of scaleimage, 1 = 100%, 0.1=10% etc.) :\")
scaleend#=Input$(\"input size at end of animation: \")
frames%=Input$(\"input the desired number of frames: \")
framerate%=Input$(\"input the desired framerate: \")
Cls
;animation(frames,xstart,xend,ystart,yend,scalestart,scaleend,framerate)



;Function animation(frames,xstart,xend,ystart,yend,scalestart,scaleend,framerate)
xdiff#=(xend-xstart)/frames
ydiff#=(yend-ystart)/frames
scalediff#=(scaleend-scalestart)/frames
For i = 0 To frames-1
Cls
scalneed=0
LockBuffer BackBuffer()
For x=0 To imagew-1
For y=0 To imageh-1
WritePixelFast xstart+(xdiff*i)+x,ystart+(xdiff*i)+y,pix(x,y)
Next
Next
UnlockBuffer BackBuffer()
If Abs(scalediff)>0
scaled=CreateImage(800,600)
GrabImage scaled,0,0
Cls
ScaleImage scaled,1.0+scalediff*i,1.0+scalediff*i
MidHandle scaled
DrawImage scaled,400,300
scaled=CreateImage(800,600)
GrabImage scaled,0,0
HandleImage scaled,0,0
Cls
framecount[i]=scaled
scalneed=1
EndIf
If scalneed=0
scaled=CreateImage(800,600)
GrabImage scaled,0,0
framecount[i]=scaled
EndIf
Next

Print \"all processing for the animation has finished\"
Print \"to start the animation press a key\"
Print \"to restart the animation after that\"
Print \"and not return to main programm\"
Print \"press space after it's finished\"
Print \"if you'd like to save your animation as single images press F1\"
Print \"if you'd like to save your animation as an 'animated bmp' press F2\"
Delay 100
Print \"these are your animations stats:\"
Print \"frames:\"+frames+\"| starting x:\"+xstart+\"| final x:\"+xend+\"| framerate:\"+framerate
Print \"duration:\"+frames/framerate+\"| starting y:\"+ystart+\"| final y:\"+yend+\"| scalefactor:\"+scalediff
frametimer=CreateTimer(framerate)
WaitKey()
FlushKeys()

.replayanim
For i=0 To frames-1
Cls
DrawImage framecount[i],0,0
WaitTimer(frametimer)
Flip

Next

WaitKey()
Cls
Flip
If KeyHit(57) Then Goto replayanim
FlushKeys()
If KeyHit(59)
FlushKeys()
filenamesingles$=Input$(\"filename and path (without type spec): \")
For i=1 To frames
SaveImage(framecount[i-1],filenamesingles$+i+\".bmp\")
Next
EndIf
If KeyHit(60)
FlushKeys()
CreateImage huge,800*frames,600
SetBuffer ImageBuffer(huge)
For i = 0 To frames-1
DrawImage framecount[i],i*800,600
Next
SetBuffer BackBuffer()
filenameanimation$=Input$(\"filename and path (without type spec): \")
SaveImage(huge,filenameanimation$+\".bmp\")
EndIf

;End Function


Bei mir läuft es bugfrei, auch das scalen ohne prob.

edit: habe framcount fixed auf 1000 also bitte keine frames grösser tausend wählen.

edit: rechtschreibfehler, hatte ein "e" bei der globalen definition des blitz arrays framedcount vergessen
  • Zuletzt bearbeitet von hitokiri am So, Mai 08, 2005 18:05, insgesamt 2-mal bearbeitet

hamZta

Administrator

BeitragSo, Mai 08, 2005 11:39
Antworten mit Zitat
Benutzer-Profile anzeigen
---------------------------
Blitz Basic
---------------------------
Blitz array sizes must be constant
---------------------------
OK
---------------------------


Auch wenn deine GoTos Absicht sind verbessert nicht die übersichtlichkeit -.-

ausserdem, wie können gotos unabsichtlich gesetzt sein?
Blog.
 

hitokiri

BeitragSo, Mai 08, 2005 14:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Seltsam, bei mir hatte es funktioniert. *kopfkratz*
Naja, dann muss ich wohl oder übel doch ne maximale frameranzahl einsetzen. wollte ich eigentlich wenn möglich umgehen...
Wie willst du Fehlerkorrektur sonst intelligent lösen ausser mit goto ???
du musst eine sprungmarke setzen und ob du dann ne function schreibst die dir dann eben "error" ausgibt und danach zur jeweiligen sprungmarke springt, also auch die angabe braucht wann sie zu welcher sprungmarke springen soll, oder nen goto...da finde ich goto tausendmal schöner.

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group