-
September 23rd, 2015, 07:29 AM
#1
Ruby programming
Wasn't really sure where to put this but this seemed like the best fit, if it's in the wrong spot, delete it or move it please.
Alright, so I've decided I'm going to create an app, I've learned a lot and now is the time for me to put my training into action, I have an idea of what I want to do. I'm going to make a game similar to solitaire the only problem is I have no idea how to start this or even how to begin...
So my question is, how would you start if you where going to create a game like what I'm doing? Would you use classes, a superclass, just variables, methods etc.? I'm trying to get a grasp on what I want to accomplish within this game. I've made games already (just text games though "You walk through a door, what do you want to do?" gets.chomp! etc..)
So I'm looking for all possible solutions and looking very deep into how this will work and how this is going to be achieved I want to learn something from this experience. Please give examples of what you would personally use.
Thank you ahead of time!!
What I have so far is this: *KEEP IN MIND I'M STILL NEW TO RUBY AND PROGRAMMING*
Code:
class Game
attr_accessor :deck, :rank, :suit, :player
end
class Deck < Game
def initialize(deck)
@deck = amount_of_cards
amount_of_cards = 52
Deck.shuffle!
end
end
class Rank < Game
def initialize(rank)
@rank = card_rank
card_rank = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']
end
end
class Suit < Game
def initialize(suit)
@suit = card_suit
card_suit = ['D', 'C', 'H', 'S']
end
end
class Player < Game
def initialize(player)
@player = player
end
end
-
September 23rd, 2015, 11:58 AM
#2
Re: Ruby programming
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|