![]() It shows a splash screen, which is just a Panel control. RedBack calls a method called StartGame to get things underway. The first step is creating the initial tableau or starting position. However, that was where it was in the original VB6 version so that is where it lives now. This may not be the best place to put it a configurable game engine would be better. The actual game logic is implemented on the form. If Not oldPile.TopCard Is Nothing Then If = False Then _Log.MoveCardFromListToPile((pile.StackKey)) _Log.MoveCardFromPileToList((oldPile.StackKey)) This class handles that complexity.įor cardIndex = oldPile.Count To startIndex Step -1 Since the RedBack version of Spider implements unlimited undos and deal undos, it needs to track every move and provide methods to undo them. If that card has already been dealt, it tries again. The function selects a random card based on deck, suit and rank. _CardRecords(deck, rank, suit).Seq = _SeqĬard = _Cards.Item( CStr(deck) & ". _CardRecords(deck, rank, suit).Dealt = True Loop Until _CardRecords(deck, rank, suit).Dealt = False Public Function DealCard( ByVal faceUp As Boolean) As Cardĭim card As Card = Nothing If Me.CardsLeft = 0 Then Return Nothing Exit Function End If Select Case _DealModeĭeck = GetRandom(_ONE, _Decks - 1) It declares public Enums to define the possible decks, suits and ranks. The class Card represents an instance of a card. This is a card game, so it needs a class that represents a single card. ![]() They could more easily be created at run-time but this was a legacy from the original VB6 version. It also has 104 picture boxes to hold card images. It has a panel control for the splash screen, eight panel controls for completed suits, and ten panels for the cards that are dealt. I didn't want to implement this menu option, but my wife was adamant. There is a menu option labelled "I hate spiders" to turn off this beautiful background feature. These are used to create a tiled background image. ![]() I wanted a spider themed background so I obtained some Australian spider photographs from an Australian expert on spiders, with his permission, of course. It is not perfect, because the pixels are changed before the image gets scaled. Public Sub CleanUpCorners( ByRef bmp As, color As Drawing.Color)ĭim limits() As Integer = įor y As Integer = 0 To 6 For x As Integer = 0 To limits(y) - 1īmp.SetPixel(bmp.Width - 1 - x, y, color)īmp.SetPixel(x, bmp.Height - 1 - y, color)īmp.SetPixel(bmp.Width - 1 - x, bmp.Height - 1 - y, color)īmp = New Bitmap(clsResources.GetImage( " c" +. Instead, I added code to make the offending pixels transparent. That would have required 52 x 4 separate edits working at the pixel level. I didn't feel like going back and manually resetting those few pixels to transparent. Initially, the corner areas outside the border were white and they looked bad on the screen. I added a two pixel wide black border with rounded corners. I then processed the images using Paint.Net. I created the card faces by running an old deck of cards through a sheet-feed scanner. By today's standards, they are too small, and scaling them up reduced the image quality. The first version used the card graphics that came with early Windows 3.1 solitaire games. You can make moves simply by clicking the card you want to move.You can undo moves and deals right back to the beginning of the game.Redback has some irregular features that I added at my wife's request: ![]() I recently redid the graphics and tidied up the code for this article. It is a close relative of the Black Widow. In keeping with the original name, I called my version RedBack after an infamous Australian spider. I added more spider graphics plus an option to hide the pictures for the arachnophobic. In 2004, I converted the game from VB6 to VB.NET, using the 1.1. This game didn't work under Windows 95 - it would load but the cards wouldn't show - so I wrote my version as a learning exercise in Visual Basic object based programming. RedBack is modelled on the Windows 3.1 shareware game Arachnid that my wife loved to play. The classes that represent cards, stacks of cards, and move history could be reused for other card based solitaire games since the specific game logic is on the tableau form. The program implements the standard two-deck version of Spider. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |