Week #24: Game Programming

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 16236 Views - Last Post: 18 August 2010 - 07:24 PM

#16 Guest_Ryoma*


Reputation:

Re: Week #24: Game Programming

Posted 06 July 2010 - 02:00 PM

View PostRyoma, on 06 July 2010 - 12:56 PM, said:

I made a game almost like Risk in vb.net
Posted Image
this is a ss when the game starts

Sry for dubble posting but i wanted to gave you guys the exe file
The database is in there to it is required

Risico
you can donwload it here
Was This Post Helpful? 1

#17 siylence  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 10-June 07

Re: Week #24: Game Programming

Posted 06 July 2010 - 11:34 PM

I built this Tic-Tac-Toe game in Flash out of boredom about a year ago:
Tic-Tac-Toe
Was This Post Helpful? 1
  • +
  • -

#18 carltech  Icon User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: Week #24: Game Programming

Posted 07 July 2010 - 03:58 PM

took me about a dozen tries to beat the tic tac toe...good job
Was This Post Helpful? 0
  • +
  • -

#19 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: Week #24: Game Programming

Posted 07 July 2010 - 09:59 PM

Just had to create a paper, rock, scissors game for my Java class. Thought I'd try transferring it to Ruby. I'm sure it could have been done better than what I just threw together. Any Rubyists out there please let me know what I could have done different/better.

class Roshambo
  def initialize
    @choice = 0
    @roshambo = ["paper", "rock", "scissors"]
  end

  def set_roshambo(choice)
    @choice = choice
  end

  def get_roshambo
    return @roshambo.at(@choice)
  end
end

class Player
  attr_accessor :name, :roshambo

  def initialize name
    @name = name
    @roshambo = Roshambo.new
  end

  def set_roshambo choice
    @roshambo.set_roshambo(choice)
  end

  def get_roshambo
    return @roshambo.get_roshambo
  end

  def compare(player2)
    if @roshambo.get_roshambo == player2.get_roshambo
      puts "It's a tie!"
    elsif (@roshambo.get_roshambo == "paper" and player2.get_roshambo == "scissors") or
            (@roshambo.get_roshambo == "rock" and player2.get_roshambo == "paper") or
            (@roshambo.get_roshambo == "scissors" and player2.get_roshambo == "rock")
      puts "You Lose! :(/>"
    else
      puts "You Win!! :D/>"
    end
  end
end

class Opponent < Player
  def initialize
    @name = "Fred"
    @roshambo = Roshambo.new
  end

  def set_roshambo
    choice = rand(3)
    @roshambo.set_roshambo(choice)
  end
end

jon = Player.new("Jon")
opp = Opponent.new

puts "Make your choice \n1. Paper\n2. Rock\n3. Scissors\n<1,2, or 3>\n"
choice = gets.chomp.to_i - 1

jon.set_roshambo(choice)
opp.set_roshambo

puts "You chose: #{jon.get_roshambo}"
puts "#{opp.name} chose: #{opp.get_roshambo}"

puts jon.compare(opp)
puts "Thanks for playing!"


Was This Post Helpful? 0
  • +
  • -

#20 laserbeak43  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 134
  • Joined: 07-November 09

Re: Week #24: Game Programming

Posted 10 July 2010 - 09:34 AM

this is the latest challenge?
Was This Post Helpful? 0
  • +
  • -

#21 .Aaron  Icon User is offline

  • Rock, paper, scissors, lizard, Spock
  • member icon

Reputation: 61
  • View blog
  • Posts: 2,859
  • Joined: 04-August 09

Re: Week #24: Game Programming

Posted 10 July 2010 - 11:17 AM

Yea, so far. There should have been another one up by now but I guess they're just a bit behind. Or they've finaly ran out of challenge suggestions for the time being. Least now I'm not as far behind, this week sure didn't leave me much time for this stuff.
Was This Post Helpful? 0
  • +
  • -

#22 laserbeak43  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 134
  • Joined: 07-November 09

Re: Week #24: Game Programming

Posted 11 July 2010 - 09:01 PM

Attached Image

Well,
It's 11:56PM and I haven't gotten multi-threading tackled yet, but I did learn a lot for 1.5 days into the 52 week marathon. :) So, here's my unfinished Simon game:) You'll need the NAudio library to use it.

-edit-
It's just source, you'd have to build the binary.

Attached File(s)


This post has been edited by laserbeak43: 11 July 2010 - 09:03 PM

Was This Post Helpful? 0
  • +
  • -

#23 Shane Hudson  Icon User is offline

  • D.I.C Technophile
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,286
  • Joined: 06-December 09

Re: Week #24: Game Programming

Posted 12 July 2010 - 05:04 AM

I did a 2 player Tic-Tac-Toe... not quite worked out how to do AI yet! No fancy GUI but the buttons are dynamically generated, to the size of your window... took a while for me to perfect!

Download the exe here.

This post has been edited by Shane Hudson: 12 July 2010 - 05:06 AM

Was This Post Helpful? 0
  • +
  • -

#24 logicandchaos  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 40
  • Joined: 24-January 10

Re: Week #24: Game Programming

Posted 17 August 2010 - 01:49 PM

here is my 1st C# game it uses XNA and flatredball, it is kinda like asteroids, but i actually got the idea from intellivision's space hawk! you are a lone spaceman that must try to survive the harsh environment of space, it is fairly simple, and has the crude caveman-like drawings that could only be made by a programmer :P here is the link to the video: http://www.youtube.c...h?v=NCMvBab8Eeo here is the link for the game: http://ifile.it/4m5zcxw
Was This Post Helpful? 1
  • +
  • -

#25 laserbeak43  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 134
  • Joined: 07-November 09

Re: Week #24: Game Programming

Posted 17 August 2010 - 08:43 PM

View Postlogicandchaos, on 17 August 2010 - 12:49 PM, said:

here is my 1st C# game it uses XNA and flatredball, it is kinda like asteroids, but i actually got the idea from intellivision's space hawk! you are a lone spaceman that must try to survive the harsh environment of space, it is fairly simple, and has the crude caveman-like drawings that could only be made by a programmer :P here is the link to the video: http://www.youtube.c...h?v=NCMvBab8Eeo here is the link for the game: http://ifile.it/4m5zcxw

hahaha, cool!
Was This Post Helpful? 0
  • +
  • -

#26 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: Week #24: Game Programming

Posted 18 August 2010 - 07:24 PM

Wrote a simple memory game. Display a series of numbers individually, display each for a set amount of time. Then allows user to enter the number pattern. Player wins if their pattern matches the one displayed. The amount of numbers displayed increases and the length of time the numbers are displayed decreases each round. (got the idea from the Simon game above, just using numbers instead of colors)

Main Game Class:
public class Simon
    {
        public List<int> Choices { get; private set; }
        public int Level { get; private set; }
        private Random random { get; set; }
        private Timer timer { get; set; }

        public Simon()
        {
            this.Level = 1;
            random = new Random();
        }

        public void Start()
        {
            bool isRunning = true;

            Console.WriteLine("You are Level " + this.Level + ". Press <Enter> to begin");
            Console.ReadLine();

            while (isRunning)
            {
                this.Setup();
                this.ShowChoices();

                if (isWinner())
                {
                    Console.WriteLine("You got them all right! \nYou've gained a level.");
                    LevelUp();
                    Console.WriteLine("Level: " + this.Level + "\nPress Enter to Begin Next Round");
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("You Lose! \n The correct choices were:");
                    foreach (int choice in Choices)
                    {
                        Console.Write(choice + " ");
                    }

                    Console.WriteLine("\nWould you like to try again? < Y or N >");
                    string response = Console.ReadLine();
                    if (response != "Y" && response != "y") isRunning = false;
                }
            }
        }

        private bool isWinner()
        {
            List<int> pChoices = playerChoices();
            int i=0;

            foreach (int choice in pChoices)
            {
                if (choice != Choices[i++]) return false;
            }

            return true;
        }

        private void Setup()
        {
            this.Choices = new List<int>();
            this.timer = new Timer(2500 - (this.Level * 250));

            for (int i=0; i<this.Level + 3; i++)
            {
                int num = random.Next(4)+1;
                Choices.Add(num);
            }
        }

        private void LevelUp()
        {
            this.Level++;
        }

        private void ShowChoices()
        {
            int i = 0;

            timer.Execute(delegate(){
                Console.Clear();
                if (i != Choices.Count)
                    Console.WriteLine(Choices[i++]);
                else
                    timer.End();
            });
        }

        public List<int> playerChoices()
        {
            List<int> pChoices = new List<int>();

            Console.WriteLine("Enter the " + Choices.Count + " numbers in the correct order");

            for (int i=0; i < Choices.Count; i++)
            {
                Console.Write("Choice " + (i+1) + ":");
                pChoices.Add(Convert.ToInt32(Console.ReadLine()));
            }

            return pChoices;
        }
    }



Chose to implement my own timer just to see if I could

Timer Class:
public class Timer
    {
        public int Interval { get; set; }
        public int Duration { get; set; }
        private DateTime end { get; set; }
        private DateTime next { get; set; }
        private bool isRunning { get; set; }
        
        /***************************************
        Default Constructor - will just execute the code 
            block or function once and quit
        ***************************************/
        public Timer()
        {
            Interval = 0;
            Duration = 0;
        }

        /***************************************
        Constructor - Executes the function once per
		interval until End() is called
        ***************************************/
        public Timer(int interval)
        {
               this.Interval = interval;
               if (this.Interval < 250) this.Interval = 250;
               this.Duration = 0;
        }

        /***************************************
        Constructor - Executes the function once per 
        	interval until duration is reached
        ***************************************/
        public Timer(int interval, int duration)
        {
            this.Interval = interval;
            if (this.Interval < 250) this.Interval = 250;
            this.Duration = duration;
        }

        /***************************************
        Execute Method - Executes the given Action
        ***************************************/
        public void Execute(Action action)
        {
            if (this.Interval > 0)
            {
                this.getEnd();
                this.getNext();
                this.isRunning = true;

                while (DateTime.Now != this.end && this.isRunning)
                {
                    if (DateTime.Now == this.next)
                    {
                        action.Invoke();
                        this.getNext();
                    }
                }

            }
            else
                action.Invoke();
        }

        /***************************************
        Method Next() - used by the next property to get 
        	the time of the next interval
        ***************************************/
        private void getNext()
        {
            if (this.Interval > 0)
                this.next = DateTime.Now.AddMilliseconds(this.Interval);
        }

        /***************************************
        Method End() - gets the End Time and stores it
        	in the end property
        ***************************************/
        private void getEnd()
        {
            if (this.Duration > 0)
                this.end = DateTime.Now.AddMilliseconds(this.Duration); // if duration is > 0 set a duration
            else
                this.end = new DateTime(2000,1,1); // if duration <= 0 create a time that can't be reached 
        }

        /***************************************
        Method End() - manually stop the timer
        ***************************************/
        public void End()
        {
            this.isRunning = false;
        }
    }



Main:
    public class SimonMain
    {
        public static void Main(string[] args)
        {
            Simon simon = new Simon();
            simon.Start();

            Console.ReadLine();
        }
    }


This post has been edited by Nakor: 18 August 2010 - 07:43 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2