Ari feldman spritelib10/29/2022 ![]() Ari feldman spritelib code#To add that 3D effect, create two more layers of stars by duplicating the code in FormCreate (everything from “with” to “end” inclusive), setting the subsequent dSpeed values to 8 and 12 and the image.PatternCount div values to 4 and 2. Immediately under the procedure declaration (and before the “begin” statement) insert… Now click the Events tab, double-click beside OnCreate and add this code to the new procedure …Ĭhips := image.PatternCount - random(image.PatternCount div 8) … and choose Form1 in the Object Inspector. Procedure TBackground.DoMove (MoveCount : Integer) Procedure DoMove (MoveCount : Integer) override Set the timer interval to 30, load the ImageList with Stars.bmp (from the free disk), give it the name “Stars” and set its PatternHeight and PatternWidth properties to 16.Ĭreate an OnTimer event for the usual DXTimer code … Neat, eh? Now I’ll show you how we get there.Ĭreate a new project and add the usual DelphiX suspects DXImageList, DXTimer, DXSpriteEngine and DXInput. Take a look at Demo2.exe to see where we’re heading. You’ll often find it in the form of a constantly moving backdrop of stars in space games. There’s one other type of background that I call set-and-forget because it chugs along all by itself. (See the sidebar “Sprite libraries”.) In fact, I’m so confident you can make the necessary changes yourself, I’ve only added the two graphics files - “Plane” and “Island background” - to this month’s CD. It’s essentially the same code as last month, with a few snips and tweaks and some better graphics courtesy of Ari Feldman’s “1945” collection. Ari feldman spritelib Pc#If your background’s big enough and varied enough you can reduce or eliminate the “repetition fatigue” caused by continually scrolling past the same old thing.įor a demonstration, check out Demo1.exe on the PC World Plus disk. You can use the TDXDraw field as a window onto a much larger graphic that scrolls along behind your sprite. (Try stretching out the background used in last month’s program and you’ll see what I mean)īut you don’t have to display all of the background in one go. Setting it to True - as in the statement “Backgrnd.Tile := True ” causes the image to be tiled horizontally and vertically as many times as necessary to fill the area defined by TDXDraw. ![]() Such backgrounds are known as ‘tiles’ because, like the patterned bathroom variety, you can go on placing them end-to-end forever and never vary the design.ĭelphiX makes tiling a doddle with its TBackgroundSprite.Tile command. ![]() L ast month I introduced the concept of a continuous background for our animated action, rather like the backdrops you see on cheap cartoons where the character continually runs past the same landmarks time and time again. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |