![]() |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Liste der Anhänge anzeigen (Anzahl: 1)
Nachdem ich noch ein paar Probleme behoben habe, läuft jetzt auch die Videoplayer-Demo zum großen und ganzen untern Linux (aktuelle CVS-Version). Einzig der "Pause"-Knopf will noch nicht so, da TThread.Suspend unter Linux nicht implementiert ist. Als Beiweis habe ich einen kleinen Screenshot angehängt.
Es wird in den nächsten Tagen ein "neues" Release (sowas wie 0.4.6) geben, das einige kritische Probleme (wie zum Beispiel den Bug in der XML-Klasse) behebt. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Gibt es denn keine andere Möglichkeit, den Thread anzuhalten? Ein Pause-Flag in die Klasse, das der Thread in jedem Schleifendurchlauf überprüft und nur dann weiter abspielt. wenn es False ist?
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Ich finds super, wie du dich um dein Projekt kümmerst. Kann man dir vllt. irgentwie helfen? Ich mache 2009 mein Abi in Englisch und Informatik, willst du vllt. die Tutorials übersetzt haben, oder sowas?
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Das Suspend habe ich jetzt aus AdVideoTexture.pas entfernt, jetzt sollte das auch mit Linux funktionieren.
Das Particelsystem habe ich mir nochmal angeschaut, konnte aber keine Fehler entdecken. Zitat:
Z.B.: ![]() Ich selbst habe leider keine Zeit mich auch noch um das schreiben der Tutorials auf Englisch zu kümmern, von daher wäre das wirklich toll. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Mit den Übersetzungen hab ich auch irgendwann mal angefangen aber es dann wohl wieder vergessen... Seis drum, mir war sowieso grad langweilig, ich hab mal den verlinkten Text übersetzt, grobe Fehler dürften keine drin sein, ich habs dir mal per PN geschickt.
Im Übrigen fehlt in der deutschen Version (und daher auch in meiner Übersetzung, weil ich mir nicht sicher war, wie die Syntax für URLs ist) der Link zu TortoiseCVS. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Jo gut, mit dem war ich auch gerade fast fertig :-D
Wenn es okay für dich ist, werde ich das beste aus beiden Versionen nehmen. Was mir auch aufgefallen ist, das neue ToroitseCVS sieht ganz anders aus als auf den Screenshots. Stört aber nicht wirklich, die Felder sind fast die gleichen. Edit: So, das wäre meine Version. Ich habe nur ein paar Dinge ausgetauscht, die sich für mich komisch angehört haben. Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
Romi, kannst du mir den BB-Code von dem geposteten Tutorial schicken? Dann baue ich das sofort ein. Um auf die anderen Tutorials zuzugreifen, einfach cvstut1ger.bb durch so etwas wie tut1ger.bb etc. ersetzten. Der Dateiname ist derselbe wie der im bb-Parameter des PHP-Scripts angegebene. Bevor ich es vergesse, der Setup-Dialog läuft nun auch einwandfrei unter Linux. Hab davon auch noch einen Screenshot angehängt. Mit der aktuellen CVS-Version bin ich übrigens äußerst zufrieden: Hab das ganze einfach unter Linux als Annonymous ausgecheckt, AndorraOGL.lpi geöffnet, auf kompilieren geklickt, die erzeugte "AndorraOGLLaz.dll" zu "AndorraOGLLaz.so" umbenannt, VideoPlayer.lpi geöffnet, F9 gedrückt, fertig. Das ganze setzt natürlich voraus, dass Acinerella installiert ist. Auch der Pauseknopf funktioniert nun so, wie er soll. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Romi, könntest du mir bitte die "Dinge, die dir komisch vorgekommen sind" mitteilen? Ich arbeite immer daran, mein Englisch zu verbessern, und ich dachte zwar, dass ich keine Fehler drinhatte, aber ich kann mich natürlich auch irren.
Weil ich momentan zu viel Freizeit habe (bzw. keine Lust auf das, was ich eigentlich zu tun hätte), hab ich gleich noch das nächste übersetzt: Andorra 2D tutorials Part 2 - The first graphic Introduction In the last tutorial you have learned how to initialise Andorra 2D. The result was a black window. However, we could have achieved this with much less effort. Therefore we now continue with our sample programme - we load an image and display it. The image list What we need first of all is a so-called "ImageList", which conveniently stores all images that have been loaded into it. Now we need a variable of the type "TAdImageList" which we call "AdImageList" and create in FormCreate. Note that the list may only be created after calling AdDraw.Initialize. So we continue writing below the line "Application.OnIdle := Idle":
Code:
Now we want to add a image to the list. This is done by the following code:
AdImageList := TAdImageList.Create(AdDraw);
Code:
The Imagelist's function "Add" adds a image of the type "TAdImage" with the corresponding name and returns it.
with AdImageList.Add('image') do //A image called 'image' is added to the list.
begin Texture.LoadGraphicFromFile('texture.bmp'); //A image is loaded into the texture end; AdImageList.Restore; //To be explained later Why does this "TAdImage" now have a sub-object "Texture" again? Are an image and a texture not the same? As the following picture shows, this is not quite true in Andorra2D... ![]() The image, the object we just added to the image list, that is, is merely some kind of base frame on which the texture is painted. So the "Image" or "Picture" is just a canvas whereas the texture is what is painted on it. Now another uncertainty has to be clarified: The job of the procedure "Restore". When the image list's function "Restore" is being called, it just calls the "Restore" function of each image. Therefore the following code would do the same:
Code:
However, this method is somewhat laborious when many entries are added to the image list.
with AdImageList.Add('image') do //An image called 'image' is added to the list.
begin Texture.LoadGraphicFromFile('texture.bmp',false,clNone); //A texture is loaded into the image without transparency. Restore; end; Now it only has to be said what this "Restore" does. Let us remember the image mentioned earlier: The image is just the base frame on which the texture is painted. Now the base frame cannot know the size of the texture we loaded. Therefore the base frame is recreated with the appropriate size when the function "Restore" is called and according links are placed. When one forgets calling "Restore", an error message is the most likely result. Loading the images The texture provides the following procedure to load and save images:
Code:
Only the last two methods are relevant for loading graphics directly. The first few write the texture in a file format of Andorra 2D and are not suitable for loading "normal" graphic files.
procedure LoadFromStream(AStream:TStream);
procedure SaveToStream(AStream:TStream); procedure SaveToFile(AFile:string); procedure LoadFromFile(AFile:string); procedure LoadGraphicFromFile(AFile:string;Transparent:boolean;TransparentColor:TColor); procedure LoadFromGraphic(AGraphic:TGraphic); "LoadFromGraphic" gets the transparency parameters directly from the loaded graphic. By default, Andorra 2D can load all standard graphics formats of the VCL - *.bmp (BItmap), *.dib (Device Independend Bitmap) and *.wmf (Windows Meta File) that is. To load other formats, appropriate loader libraries have to be added to the uses clause. These libraries add themselves to a list in "AdDraw" on initialisation. Andorra 2D can then load these formats and (if implemented accordingly) save them, too. To load PNG images, the unit "AdPNG" has to be added to the uses clause, for JPEG images the unit "AdJPEG". For loading the images, other libraries are needed in most cases. These have to be installed independently from Andorra 2D. For the PNG format the library "PNGDelphi" ( ![]() Rise the curtain Now we are only a small step away from displaying our first image on the screen. The following line, which we add to the procedure "Idle" between "BeginScene" and "EndScene", does this.
Code:
Now what do these four parameters of the procedure "Draw" mean? Here AdDraw is the so-called "surface" which is the image is painted on. The next two parameters specify the position on the screen, at which the image is to be painted. The third parameters specifies the so-called "PatternIndex", which handles animations, of which more later.
AdImageList.Find('image').Draw(AdDraw,0,0,0);
Now there is not only the function "Draw" alone to draw images, this would be fairly little. The TAdImage object also provides these other procedures: add
Code:
A more detailed description can be found in the documentation:
//Simplest method for drawing
procedure Draw(Dest:TAdDraw;X,Y,PatternIndex:integer); //Draw an image stretched procedure StretchDraw(Dest:TAdDraw;const DestRect:TAdRect;PatternIndex:integer); //Draw an image stretched and with a certain alpha value (from 0 like fully transparent to 255 like completely opaque) procedure DrawAlpha(Dest: TAdDraw; const DestRect: TAdRect; PatternIndex: Integer; Alpha: Integer); //Draw an image stretched with additive colour blend and a certain alpha value (from 0 like fully transparent to 255 like completely opaque) procedure DrawAdd(Dest: TAdDraw; const DestRect: TAdRect; PatternIndex: Integer; Alpha: Integer); //Draw a stretched image completely black and with a certain alpha value (from 0 like fully transparent to 255 like completely opaque) procedure DrawMask(Dest: TAdDraw; const DestRect: TAdRect; PatternIndex: Integer; Alpha: Integer); //Draw an image rotated. Angle is a value from 0 to 360 degrees. CenterX and CenterY denote the centre of the rotation. The two values range from 0 to 1, so 0.5 and 0.5 are exactly the centre of an image. procedure DrawRotate(Dest: TAdDraw; X, Y, Width, Height: Integer; PatternIndex: Integer; CenterX, CenterY: Double; Angle: Integer); procedure DrawRotateAdd(Dest: TAdDraw; X, Y, Width, Height: Integer; PatternIndex: Integer; CenterX, CenterY: Double; Angle: Integer; Alpha: Integer); procedure DrawRotateAlpha(Dest: TAdDraw; X, Y, Width, Height: Integer; PatternIndex: Integer; CenterX, CenterY: Double; Angle: Integer; Alpha: Integer); procedure DrawRotateMask(Dest: TAdDraw; X, Y, Width, Height: Integer; PatternIndex: Integer; CenterX, CenterY: Double; Angle: Integer; Alpha: Integer); //Similar to StretchBlt from the Windows GDI. Draws a certain part of the image magnified or downscaled. procedure DrawEx(Dest:TAdDraw; SourceRect,DestRect:TAdRect;CenterX,CenterY:integer;Angle:Integer;Alpha:Integer;BlendMode:TAd2dBlendMode); ![]() You best try these methods on our sample image. However, I will explain some of them in the tutorials. As you might have noticed, Andorra 2D uses its own types such as "TAdRect", which are located in the unit "AdTypes". Therefore the VCL unit "Types" and "Windows" do not have to be used. Fullscreen Many games run fullscreen. You can also easily set it up in Andorra 2D. FOr this you only have to navigate to the "OnCreate" method of Form1. Add the following lines before "AdDraw.Initialize":
Code:
Note that the graphic output of the AdDraw has to be on a TForm or the fullscreen display will not work.
with AdDraw.Display do
begin Width := 800; Height := 600; BitDepth := ad32Bit; //The colour depth. The values "ad16Bit" and "ad32Bit" are allowed here. DisplayMode := dmFullscreen; end; And now your Andorra 2D application already runs fullscreen. However, you have to ensure that both your monitor and your graphics card support the specified resolution. There is a minor trick with which you can achieve fullscreen without having to change the resolution. Instead of the above lines just write:
Code:
With this only the size of your form is changed.
BorderStyle := bsNone;
Top := 0; Left := 0; Width := Screen.Width; Height := Screen.Height; Important: With the first method, it is tried to run the programme in a real overlay fullscreen mode. This means that the graphics output is a great deal faster because control elements of other applications are not drawn anymore. With the second method the window only covers all the others, so not as many FPS can be reached. Movements and animations You best delete all changes from the programme which you have made in this tutorial thus far. Now we want to have an animated figure run across the screen. As soon as it has reached one edge of the screen, it should run back on an arbitrary Y position. For this we first need the image of the animated figure - which looks like this: ![]() As we see, this image is effectively constructed like a filmstrip. To show a part of the animated, only a part of the texture is drawn. You might wonder why we don't have a separate image file for each step of the animation now, (also called frame or pattern) but this would simply be inefficient because it is better for the graphics card to manage one texture the size of 512x512 than many small ones the size of 128x128. The image of the figure can be downloaded ![]() ![]() First we have to load the image with the animations into the engine. This is done almost like we did before:
Code:
With PatternWidth and PatternHeight the height and width of a frame are set, in our case to 96. By calling the "Restore" instruction, Andorra 2D creates some kind of map on which stores the number and position of each frame. In fact, Andorra counts from left to right and then from up to down. Also, the numbering starts from zero, as shown on the picture above.
AdImageList := TAdImageList.Create(AdDraw);
with AdImageList.Add('figure') do begin Texture.LoadGraphicFromFile('boy.bmp',true,clFuchsia); //This time the image is loaded transparently PatternWidth := 96; PatternHeight := 96; end; AdImageList.Restore; If you now want to draw a single frame from the animation, the "PatternIndex" of the drawing function comes into play. Here you can simply specify the number of the frame and it is drawn. But we wanted to have the figure run across the screen, so we take care of the animation first. For this we need a variable of the type Single or Double. You will see later why it cannot just be a simple Integer. So we add a variable "Pattern" to the variable declarations in the interface clause of the programme so that the line looks vaguely like this:
Code:
In "Idle" we now increment Pattern in each step and redraw the figure afterwards. We also have to check if the pattern exceeds the pattern number as the case may be and reset it to zero if it does.
var
Form1: TForm1; Pattern:single;
Code:
However, upon executing one can see that the animations happens far too fast. The rendering loop is executed up to 5000 times in a second and the pattern is therefore incremented by 5000. Of course, instead of +1 we could now write +0.001, for example, which would cause the animation to run more slowly. However, we then have to problem addressed in the first tutorial, the animation does not run at the same speed on every PC. To avoid this problem, there is another object in Andorra 2D: The so-called "TAdPerformanceCounter" which can be found in the unit "AdPerformanceCounter". So we declare a new variable of the type "TAdPerformanceCounter" called "AdPerCounter", create an instance of the class in "FormCreate" and free it again in FormDestroy as we have done it with all the other objects, too.
Pattern := Pattern + 1;
if Pattern >= AdImageList.Items[0].PatternCount-1 then Pattern := 0; AdImageList.Items[0].Draw(AdDraw,0,0,round(Pattern)); We now write "AdPerCounter.Calculate" fairly at the beginning of the "Idle" procedure. With this, the object calculates the lapse of time between procedure runs, apart from that the well-known FPS (frames per second), which you might know from some games and which are an importand performance indicator, are calculated. With the elapsed time in milliseconds, which is stored in the variable "AdPerCounter.TimeGap", we can now create an animation which runs at the same speed on almost all PCs in the world, like this:
Code:
15 is the number of frames per second with which the animation runs here. Upon executing the animation should now run nicely slowly and at an equal speed on every computer.
AdPerCounter.Calculate;
Pattern := Pattern + 15 * (AdPerCounter.TimeGap / 1000); It was our goal to move the figure across the screen. But apart from being animated nicely now, it lacks movement. Now we first need a handful of new variables, which we declare near the others:
Code:
To move the figure we have to extend the "Draw" routine a bit.
StartPt,EndPt:integer; //The animation's start and end pattern
Y,X:single; //The figures X and Y position XSpeed:single; //The velocity in X direction
Code:
Now the figure is drawn at the position X and Y. To move it, we write the following above the drawing function:
AdImageList.Find('figure').Draw(AdDraw,round(X),round(Y),round(Pattern));
Code:
Furthermore the animation should only range from "StartPt" to "EndPt", which is why we modify the if statement a bit:
X := X + XSpeed * (AdPerCounter.TimeGap / 1000);
Code:
Now we just need a procedure to handle the figure's change of direction. We call it "SetLine", because the figure's Y position is also changed. "SetLine" should be declared within TForm1.
if Pattern >= EndPt then Pattern := StartPt;
Code:
Apart from that we need the following line in the "Idle" procedure to call the procedure when the figure leaves the edge of the screen:
procedure TForm1.SetLine;
begin //Reverse the direction XSpeed := -XSpeed; if XSpeed > 0 then begin StartPt := 0; EndPt := 7; X := -96; end else begin StartPt := 8; EndPt := 15; X := ClientWidth+96; end; //Set the Y position Y := Random(ClientHeight-96); end;
Code:
Now we only have to set the XSpeed and call the procedure "SetLine" for the first time in "FormCreate":
if ((X > ClientWidth) and (XSpeed > 0)) or
((X < -96) and (XSpeed < 0)) then SetLine;
Code:
And now our figure runs across the screen upon execution.
XSpeed := -150;
SetLine; The source code As always, the source code as a reference:
Code:
Conclusion
unit Main;
interface uses Windows, Dialogs, SysUtils, Graphics, Classes, Forms, AdDraws, AdClasses, AdTypes, AdPerformanceCounter; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormResize(Sender: TObject); private { Private-Deklarationen } public AdDraw:TAdDraw; AdPerCounter:TAdPerformanceCounter; AdImageList:TAdImageList; procedure Idle(Sender:TObject;var Done:boolean); procedure SetLine; { Public-Deklarationen } end; var Form1: TForm1; Pattern:single; StartPt,EndPt:integer; Y,X:single; XSpeed:single; implementation {$R *.dfm} procedure TForm1.SetLine; begin XSpeed := -XSpeed; if XSpeed > 0 then begin StartPt := 0; EndPt := 7; X := -96; end else begin StartPt := 8; EndPt := 15; X := ClientWidth+96; end; Y := Random(ClientHeight-96); end; procedure TForm1.FormCreate(Sender: TObject); begin ReportMemoryLeaksOnShutdown := true; AdPerCounter := TPerformanceCounter.Create; AdDraw := TAdDraw.Create(self); AdDraw.DllName := 'AndorraDX93D.dll'; if AdDraw.Initialize then begin Application.OnIdle := Idle; AdImageList := TAdImageList.Create(AdDraw); with AdImageList.Add('figure') do begin Texture.LoadGraphicFromFile('boy.bmp',true,clFuchsia); PatternWidth := 96; PatternHeight := 96; end; AdImageList.Restore; XSpeed := -150; Randomize; SetLine; end else begin ShowMessage('Error while initializing Andorra 2D. Try to use another display '+ 'mode or another video adapter.'); Close; end; end; procedure TForm1.FormDestroy(Sender: TObject); begin AdImageList.Free; AdPerCounter.Free; AdDraw.Free; end; procedure TForm1.Idle(Sender: TObject; var Done: boolean); begin if AdDraw.CanDraw then begin AdPerCounter.Calculate; Caption := 'FPS:'+inttostr(AdPerCounter.FPS); Pattern := Pattern + 15*AdPerCounter.TimeGap/1000; if Pattern >= EndPt then Pattern := StartPt; X := X + XSpeed*AdPerCounter.TimeGap/1000; if ((X > ClientWidth) and (XSpeed > 0)) or ((X < -96) and (XSpeed < 0)) then SetLine; AdDraw.ClearSurface(clBlack); AdDraw.BeginScene; AdImageList.Find('figure').Draw(AdDraw, round(X), round(Y), round(Pattern)); AdDraw.EndScene; AdDraw.Flip; Done := false; end; end; end. Now we already have created an animated figure, but the whole thing still was fairly pedestrian. Because of that we will take a look at the a solution integrated into Andorra 2D in the following tutorials: The so-called SpriteEngine. With its help one can programme all kinds of games without much effort. Copyright and licence (c) by Andreas Stöckel January 2007 Translation by 3_of_8 (Manuel Eberl) Revision 2: October 2007 Revision 3: December 2007 The content of this tutorial is subject to the ![]() |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Hi,
Grad nur 2 Sachen die mir in den ersten paar Zeilen deiner Übersetzung aufgefallen sind: 1. Zitat:
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Wie gesagt, es wäre super, wenn ihr den BB-Code anhängen könntet, damit ich davon was habe. Ich kann leider eure Posts nicht editieren und den BB-Code kopieren.
Aber schonmal Danke! :thumb: |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
OT: Dann zitiere ihn doch. ;)
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Nochmal Danke! |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Ich weiß, ich weiß... zu viel Freizeit...
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Zitat:
Hier noch ein paar Vorschläge: Zitat:
Zitat:
Zitat:
Zitat:
What is the property "Texture" of "TAdImage"? An image and a texture are the same, aren't they? The following picture will show you that they're not (at least for Andorra 2D): Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
So weit war ich. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Ich hab absichtlich das letzte genommen, weil ich vermutet habe, dass du mit dem nächsten weitermachst. :mrgreen:
Und, ja, ich habe verglichen, verstehe aber nicht so ganz, was daran seltsam klingt. |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Ich mache übrigens gerade das Tutorial zur Spriteengine. Also lass da die Finger von :-D |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Ich habe mir noch nicht die neueste Version geholt, aber funktioniert es jetzt unter Delphi 2009, dass die Grafiken richtig im ImgEdit angezeigt werden?
Und unter welcher Lizenz steht Andorra 2D und der ImgEdit (ich habe mir daraus das Zeichnen der ListView geholt)? MfG xZise |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Zitat:
Zitat:
![]() GPL: ![]() LGPL: ![]() Such dir eine passende aus :stupid: |
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Hab das zweite Tutorial, das über die Anzeige von Bildern, nochmal leicht verbessert, basierend auf romis Vorschlägen.
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Vielen Dank, ich aktualisiere das.
Könnte vielleicht nochmal jemand hierüber schauen: Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Ganz in Ordnung, ein paar Formulierungen klingen noch etwas holprig und ein paar mal häufen sich ein paar Wörter. Korrektur:
Zitat:
|
Re: Andorra 2D [Ver. 0.45, 24.12.08]
Danke, habe das abgeändert.
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Hier die Spriteengine:
Ich wollte es noch vor Neujahr fertig haben, deshalb habe ich viel gestern Nacht gemacht. Wenn also jemand Fehler findet, dann sagt bescheidt ;) Zitat:
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
@Romi: Vielen Dank, ich baue das ein.
Übrigens: Ich habe das versprochene Bugfixrelease 0.4.5.1 hochgeladen. Die wichtigste Änderung ist, dass die XML-Bibliothek nun keine Dateien mehr unbenutzbar macht. |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Zitat:
Oder bin ich einfach nur blind? :-D |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Hast du DefaultParticle auch entsprechend gecastet? Schau dir mal die SimpleParticle Demo an. Standardmäßig ist default Partikel vom Typ "TAdStdParticle":
Delphi-Quellcode:
with partengine.DefaultParticle as TAdStdParticle do
LifeTime := 0.5; |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Romi: sprite engine, nicht Spriteengine, außerdem hast du vergessen, "hier" zu übersetzen und auch steht da noch "Copyright und Lizenz" ganz unten. Genauer hab ichs mir jetzt ned durchgesehen.
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Neben den ganzen Übersetzungen habe ich die Unit AdSprites erweitert. Und zwar ist es ja nicht sinnvoll in einer Engine nach Sprites zu suchen, sondern direkt in der Liste (so kann diese Funktionalität auch in Abkömmlingen verwendet werden). Deshalb habe ich der Klasse TSpriteList "GetSpritesAt" verpasst:
Delphi-Quellcode:
Und dann das in der Engine dahingehend abgeändert, dass es wie ".Clear" bei einer ListView arbeitet indem es einfach das der Liste aufruft:
procedure TSpriteList.GetSpritesAt(ASpriteList: TSpriteList; const AX,
AY: Integer; const ASpriteClass: TSpriteClass); var i : Integer; Rect : TAdRect; begin if Assigned(ASpriteList) then begin ASpriteList.Clear; // Standard ? for i := 0 to Count - 1 do begin Rect := Items[i].BoundsRect; if (AX >= Rect.Left) and (AX <= Rect.Right) and (AY >= Rect.Top) and (AY <= Rect.Bottom) and (Items[i] is ASpriteClass) then begin ASpriteList.Add(Items[i]); end; end; end; end;
Delphi-Quellcode:
Da die andere Methode diese Aufruft muss diese nicht geändert werden.
procedure TSprite.GetSpritesAt(const AX, AY: Integer; ASprites: TSpriteList;
AClass: TSpriteClass); begin Items.GetSpritesAt(ASprites, AX, AY, AClass); end; MfG xZise PS: Diese Funktion basiert noch auf 0.4.5 (ich hoffe da gabs keine Änderung die dies nicht möglich machen). PPS: Danke für die Lizenzinformationen. |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Ähm... Das hast du mir doch schonmal geschickt, und ich habe es schon längst eingebaut. Das ist schon in dem 0.4.5.1 Release.
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Ehm nein ^^ Davor war es eine Funktion der Klasse TSprite jetzt ist es eine der Klasse TSpriteList und TSprite ruft die der TSpriteList auf ;)
MfG xZise |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Es ist die Frage ob man wirklich auf Assigned prüfen sollte am Anfang. Wenn man eine nicht valide Liste übergibt würde ich erwartten, dass eine Exception geschmissen wird und nicht einfach nur nichts passiert.
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Hmm stimmt, das wäre tatsächlich besser und nachher hilfreicher. Kann Igel ja ändern ;)
Und in welchen Format speichert AdBitmap.SaveToFile die Datei ab? Ich wollte nämlich mal gucken woran es liegt, das unter Delphi 2009 der ImageListEditor nicht funktioniert (also die Vorschau anzeige in der ListView nicht mit Transparenzen umgehen kann). Kann es sein, dass es sich um ein von dir entwickeltes Format handelt? Wie kann ich das Umstellen? Zu der Änderung im obigen Sourcecode: Statt Items.Count wird nur Count aufgerufen. Außerdem ist zu beachten, dass einige Parameter umbenannt wurden ;) Und eine Frage zur Lizenz: Ist es mir dann auch möglich das Programm unter BY-NC-SA zu stellen? (Ich habe Sourcecodeteile aus deinem ImageEditor verwendet). MfG xZise |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Aloha igel,
ich wollte jetzt eigentlich mal das TAdTextureSurface benutzen, um statische Dinge nicht in jedem Zeichenschritt zeichnen zu müssen ... allerdings gibt es ein Problem: Das Ganze funktioniert nur mit dem OpenGL-Plugin. Wenn ich das DirectX-Plugin verwende, sehe ich im AdDraw nicht, was ich aufs TextureSurface und anschließend von diesem auf das Addraw gezeichnet habe. Mit dem OpenGL-Plugin funktioniert es jedoch. Habe heute auf die aktuelle Andorra-Version aktualisiert (das Komplett-Paket, kein CVS) und natürlich auch die aktuellen DLLs in das Programmverzeichnis gepackt. Edit: Aber ansonsten ein dickes Danke für das Feature, hat mir beim performanceschwachen OpenGL einen dicken Geschwindigkeitsboost gebracht, da bei Drawball ja sehr viele Einzelelemente gemalt werden, das kann ich mir jetzt auf einfache und schnelle Weise sparen. Früher wäre das relativ doof und umständlich gewesen. Edit2: Wenn ich das Fenster vom einen Monitor auf den anderen verschiebe, vergisst das TextureSurface seinen Inhalt und ich muss ihn neuzeichnen. Ist das normal, wegen unterschiedlicher Ausgabedevices? Dann müsste ich mir wohl einen Code suchen, der das erkennt. |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Ich habe übrigens ein Speicherleck in AdDraws.pas gefunden (Z. 2601 - 2608 in Version 0.4.5.1):
Delphi-Quellcode:
Du gibst den MemoryStream nie frei!
procedure TAdTexture.SaveToFile(AFile: string);
var ms:TMemoryStream; begin ms := TMemoryStream.Create; SaveToStream(ms); ms.SaveToFile(AFile); end; Die Methode (Z. 2610 - 2619) procedure TAdTexture.LoadFromFile(AFile: string);) darunter hat nebenbei auch keinen Ressourcenschutzblock . Beabsichtigt? Übrigens geht deine Dokumentation im Internet nicht :( Oder weiß jemand, wie ich den Inhalt eines AdImages in einen PNG Datei speichere? MfG xZise |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Zitat:
|
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Hallo,
@xZise Deinen Sourcecode baue ich bei Gelegenheit ein. AdBitmap.SaveToFile schreibt die Daten (wie im zweiten Tutorial beschrieben) in ein Andorra internes Format. Zu den eigentlichen Bilddaten kommen Informationen über das Texturobjekt (Breite, Höhe, Bittiefe) hinzu. Das Memoryleak behebe ich, Ressourcenschutzblöcke füge ich hinzu. Die Dokumentation habe ich jetzt endlich erfolgreich über SSH entpackt. Wenn du ein Andorra-Bild in ein anderes Grafikobjekt speichern willst, kannst du die Funktion "SaveToGraphic" verwenden. @Florian Wenn das Surfaceobjekt mit OpenGL funktioniert, sollte es eigentlich erst recht mit DirectX gehen. Hast du mal die Surface-Demo ausprobiert? Bei dem Problem mit den zwei Monitoren kann ich leider nicht helfen, da ich nur einen Monitor habe. |
Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:28 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz