Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Friday, July 17, 2009

Learning GTK+ with C++

And boy do I miss C# already.

I learn new program languages as quickly as I get the Jones. Usually I want to join some open source program movement and advance it to the point where I'm happy with what ever I'm using and move on. Sometimes I just get interested in something and want to try it. I try and I learn and then again get bored and move on. I guess this is why I was a contract worker for so long. My latest passion is GTK+ and C++. It all looks like basic C from back in college. I was hoping that my C# work now would be closer to the standard I'd use learning this. No dice.

I found one of the reasons I can learn so quickly is the availability of high quality tutorials. Learning from a tutorial is different from just learning from reading a book. You actually have to do your homework and do the exercises. You have to get it wrong learn from the mistake and get it right. For example when I learned C# from the book I was handed by a System Architect I couldn't get my mind around the new syntax. I would leave off the trailing semi colon on every line and complain VB was easier. Now when I code in VB I forget to not add the semi colon.

So with that story in mind I found a web page with a lot of great tutorials called ZetCode. I found a lot of articles and ebook (html web pages that act like a book) tutorials. One reason I'm missing .NET and C# is that this book would be somewhere else. Like a printer friendly page or something. Also they talk about the functions that will be called and worked with but they never define them the way they would be in the object browser on Visual Studio. I like reading about function CreateWidget(string ,string, object()) I at least know what I could shove into that object and get some kind of strange error. Anytime I get an array of objects I know I'm going to error that out.

My problem with the layout and not being able to get a pdf is me being picky. I want to read the whole tutorial before I actually do the tutorial. I know I need to do the tutorial but once i read it I'll gain some kind of knowledge of what I'll be asked to do and type. It will save some on the retyping and where did I go long and what is that curly bracket for. This doesn't stop the tutorial from doing it's job and being a good tutorial.

The lack of methods and functions described like an it is in the object browser doesn't distract from the tutorial either. The information I want exists it's just in another document. The document I won't understand anyway. That's why I went out searching for a tutorial. I didn't understand the object browser always either. Now I just know enough to be dangerous with it.

I'm glad I could tell you about my pet peves.

Thursday, October 16, 2008

Correct Assumptions : More OOP With cards in games

I wrote the last post with out checking out what Micro Soft had to offer. I found that there is a card game starter kit. I downloaded it and began playing with it. I was shocked to see that what I was thinking would actually work for the handling of cards in a game.

The starter kit builds a blackjack game that you should be able to edit and expand. So i began poking around to see what was there that can be used and modded for my needs. I went to the Card Game Framework to see what was there. I found 3 classes (Card,Deck and Hand). These fit my assumptions with minor changes.

Card is built the way I assumed it would be. It encapsulates the values of the suit,faceValue, and isfaceup. This object is just for the play of this card in other collections. The values are set to private readonly fields or public get properties. That's actually good programing as it stops the programmer from attempting to change cards on the fly.

Deck unlike my deck has only one collection. It also has methods for shuffleing that collection.
Also it has a method for drawing a card. I think since black jack doesn't need a discard deck or to shuffle that deck back in those methods are missing. I can use this as an excellent start for my card based game. I can shuffle anything that looks like a deck. These can even be room tiles from games like house on hunted hill or other games with tiles.

Hand is a collection of cards and cantains a number of cards property. It's inherited by blackjack hand and hit has the rules for black jack in that. all this is wrapped by theanother class.

I know I'm on the write path to writing my game. I'm really excited by this and I can add the silverlight bits.

Saturday, October 11, 2008

A deck of cards in OO Development.

I've been thinking about this for some time. I wanted to write a web based game that uses cards. Kind of think Monoploy or Poker or Solitare. My train of thinking is how do you treat cards.

A card is simple. It's just an object with some properties. In a poker deck a Jack of clubs has a graphic. You know the picture of the jack. It has a Value a J. Now in the deck you know there is only one Jack of Clubs. So my first problem is how do I track the cards that arent in the deck.

I simply started by thinking 2 Collections. A Deck Collection with all the cards and a discard stack. So if one card is pulled from the top of the deck that card has to be placed in to the discard stack. So with this bit of design i can pull a card off the top of a unshuffled deck and place it in a discard pile.

To shuffle I can create a random number generator. And then just delete from where it's pointed from the deck collection. This will then add on top of the discard pile. Now this allows us to pick the top card of a shuffled deck and place it ontop of a discard file.

Next I want to give the cards to players. Again with the 2 Collections one for the deck and one for the discard. The program needs to track where the card is. So all the player obects have collections for cards in there hand. Also a limiting INT to limit hand size. Cards are drawn with random number from the first collection and either placed in discard or hand of a player. then the player can be quiered for there hands.

Ok that's an over view of how to deal a poker hand. Then we can add testing and how to pull the cards and game play options like betting net. I'll post some code so I can test that.

Thursday, July 31, 2008

Cool tools for version control.

I started using version control on my personal projects about a year ago now. I had a hard drive crash and I lost some project that I was working on. I cried, bought a new hard drive, reimaged and started again with the cadveat I'd do better.

So I started doing better my way. I loved subversion since I had to use it at Catalyst. It never messed up a project and it was nice and easy to use. I downloaded Tortiose and found a site to host it for free.

I thought My Version Control was a god send. I was able to tell my client he was important enough to warrent off site back up. I was able to give several other ppl working on the project with me access. they could read the wiki. Yea.. that was a move in the right direction.

At work I have a VSS system to do the source control and it's all nice inside the IDE. I never really liked it but I deal with it. and go and find who has the file locked and IMing them to get out of the file that I need. I remember the senior devs wanted a plugin into the IDE so they can "live in the IDE". I always joke about it not having a roof. Well I went to code camp (Generic name for Philly.net meeting). It was a hands on camp and dude had all kinds of amazing toys. I wanted his toys his Subversion was inside his VS his nunit test thing was inside his VS and I discovered Resharper.

The Anhk Project is that plug in. I added it tonight and I think it's really cool. I coded a bit on my project and it's sweet just what I need right there where I need it. I also added test driven.net and it works well to running unit tests with in vs.

Monday, May 26, 2008

Introduction

I'm now a believer in posting what a blog is should be about and give ppl warning before they start reading. I believe this will form a kind of anchor to my writing and will keep me on topic.

This blog is about my computer programing and hardware hacks and other cool tech stuff that I need to jot down. I will not be talking too much about work projects or techinology here. but since work does guide my learning path. I will talk about the stuff I learn and how that's coming along.

Currently I write software in C# and I use the .NET Framework to create web pages and windows applications. I also know about CSS and HTML which can be a rare thing in a windows developer.

I have 3 hardware certifcations. I can do laptop and desktop repairs. so this blog is for me.