New topic: Simple Sprite Pieces to Move on BoardGame Board?
<http://forums.realsoftware.com/viewtopic.php?t=34011> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message barrytraver Post subject: Simple Sprite Pieces to Move on BoardGame Board?Posted: Sat May 29, 2010 6:53 am Joined: Fri Sep 30, 2005 1:53 pm Posts: 477 Location: Philadelphia, PA I think I asked this question right after REAL Software had dropped sprite support and nothing had yet appeared to take its place. I'm hoping the situation may have changed by now. Suppose I want to write a simple chess game where sprite pieces (irregularly-shaped objects) move from square to square on a chessboard. Is there (again) a simple way to do that? I'm not interested in anything complicated, such as 3D graphics. 2D graphics is fine for my purposes. Sometime in the past I seem to remember that I needed to create two graphics files for each sprite: the piece itself (king, queen, rook, whatever) and a "mask," but I don't know whether that is still (or again?) relevant. I see a lot of references on this Games forum to "Open GPL," but I don't know how that fits in with REALbasic or where to begin with the basic beginner stuff. Where do I start? Advice, anyone? Barry Traver Top jefftullin Post subject: Re: Simple Sprite Pieces to Move on BoardGame Board?Posted: Sat May 29, 2010 7:59 am Joined: Wed Nov 15, 2006 3:50 pm Posts: 1588 Location: England I guess a lot depends upon how much animation will be going on. If you just want to display the pieces, then 'normal' bitmap transparency will do the trick. Even if you want to do some 'slide from here to here', you will probably get away with it. The technique can be done two ways: Mask transparency or 'white' transparency. With white transparency, you create 6 bitmaps per side (a black set and a white set) Your white pieces can not be 100% white.. maybe &cf0f0f0 is white enough The background (the part that should not be drawn on screen) should be pure white. Drag the bitmap into your RB project, and set the transparency property of the bitmap to 'white' Draw your board. Draw your pieces at the right spot using .drawpicture, and only the colored part will be drawn over the board. Alternatively, if you use a mask approach, you can have partial transparency. You start with the same image as above. Then turn all the non-pure white parts into black or some shade of grey. Thats the mask Drag both the image and the mask to the RB project, and set the mask property of the original to be the mask image by name. Again, using drawpicture will get you only the colored parts on screen. Partial transparency allows for neat techniques such as adding a grey shadow area along the lower edges of the original picture. Then have the matching area in the Mask be grey instead of black. The effect of that partial transparency is that when you draw the pieces on a non-simple background (such as textured or marble squares on the chessboard), the underlying texture will be seen 'through' the grey area like a real shadow. Moving pieces about: The simplest way is to plot the path from a to b. Then use a timer to move the piece from point to point along that path until it reaches the destination. If redrawing the whole chessboard flickers on Windows, do all the drawing into a picture object instead of to a visible canvas. When the drawing is done, copy the whole picture to a canvas on screen. _________________ RB2009 R5.1 and RB2008 Mac 10.6 + Windows 7/XP + Ubuntu Linux in Vmware on a Macbook 2.16 Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
