Jump to content

  • Log In with Google      Sign In   
  • Create Account


Manhattanisgr8

Member Since 13 Nov 2007
Offline Last Active Mar 29 2014 05:58 PM
-----

#5124292 having a couple of problems with Windown Forms

Posted by Manhattanisgr8 on 16 January 2014 - 10:16 PM

I figured it out, thank you for your help and patience.




#5111244 Help with some problems with word search game

Posted by Manhattanisgr8 on 22 November 2013 - 02:40 AM


Try removing mp first and the adding it again.

 

Thanks, that worked. Now I just need help getting pointed in the right direction for the highlighting / circling the words the user finds




#5102526 Is XNA still worth learning?

Posted by Manhattanisgr8 on 18 October 2013 - 06:38 PM


To do that, I'd need to learn C#/XNA.

 

I taught myself C# using RB Whitaker's book C# Player's guide. Then over the summer I started taking the programming classes taught at my local college where they teach Java. Going from C# to Java was a breeze. Most of the syntax is the same. The only real differences is the naming standards. Like a method in java starts with lower case where a method in C# starts with uppercase. Learning XNA will also be quite easy. Me personally, I am going to continue to use XNA to develop for Windows and the XBox 360. Then switch over to Mono once they have their own content pipeline, which is just an open source version of XNA.




#5050709 Code Review ::Pong Clone::

Posted by Manhattanisgr8 on 06 April 2013 - 06:27 PM

I just finished my first game in XNA 4.0 and would love some feedback on my code.

 

Game1:

Spoiler

 

Ball Class:

Spoiler

 

Paddle Class:

Spoiler

 

Button Class:

Spoiler

 

MainMenuState Class:

Spoiler

 

ParallaxingBackground Class:

Spoiler

 

CreditsScreenState Class:

Spoiler

 

 




#5044935 Beginner Programmer Help

Posted by Manhattanisgr8 on 20 March 2013 - 10:53 AM

Thank you both for the great advice. Would it be easier to store the players inventory in a multidimensional array in order to store the objects name and price?




#5044767 Beginner Programmer Help

Posted by Manhattanisgr8 on 19 March 2013 - 09:13 PM

I am trying to make a simple program that has the user buy items, sell items, and list their items. Just trying to practice what I have learned thus far. I have made a class to buy items, and a class to list the items. The problem I am encountering is when the "buy" class is done running and has stored the items in a playersInventory array, that data in the heap gets erased before the "list" class can list what the player has bought. Any help with this would be much appreciated, as well as any and all critique on my code.

 

Program Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuySell_Gear
{
    class Program
    {
        static void Main(string[] args)
        {
            MainMenu mainMenu = new MainMenu();

            mainMenu.MenuScreen();
        }
    }
}

MainMenu struct

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuySell_Gear
{
    struct MainMenu
    {
        static int MainMenuMethod()
        {
            Console.Clear();
            Console.WriteLine("Select what you would like to do:");
            Console.WriteLine("1. Buy");
            Console.WriteLine("2. Sell");
            Console.WriteLine("3. List");
            Console.WriteLine("4. Exit");
            return Convert.ToInt32(Console.ReadLine());
        }

        public void MenuScreen()
        {
            int menuSelection = 0;
            while (menuSelection != 4)
            {
                menuSelection = MainMenuMethod();
                Buy buy = new Buy();
                List list = new List();

                if (menuSelection == 1)
                {
                    buy.BuyStuff();
                }
                else if (menuSelection == 2)
                {
                    break;
                }
                else if (menuSelection == 3)
                {
                    list.GenerateList();
                }
                else if (menuSelection == 4)
                {
                    break;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("\t\t***Invalid Entry***");
                    Console.ReadLine();
                }
            }
        }
    }
}

Buy class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuySell_Gear
{
    class Buy
    {
        private string[] itemsForSale = new string[] { "M-16", "Grenade", "Flak Jacket", "Kevlar", "K-Bar" };
        private int[] pricesForItems = new int[] { 300, 90, 100, 50, 20 };
        private string[] playersInventory = new string[5];  //Player can only carry 5 items
        private int[] playersInventoryIndex = new int[5];
        private int playersMoney = 500;
        private int playersSelection = 0;
        private int placeItemInIndexOfPlayersInventory = 0;

        //Begin Constructors

        public string[] PlayersInventory
        {
            get { return playersInventory; }
            set { playersInventory = value; }
        }

        public int[] PricesForItems
        {
            get { return pricesForItems; }
        }

        public int[] PlayersInventoryIndex
        {
            get { return playersInventoryIndex; }
            set { playersInventoryIndex = value; }
        }

        public int PlayersMoney
        {
            get { return playersMoney; }
            set { playersMoney = value; }
        }

        private int PlayersSelection
        {
            get { return playersSelection; }
            set { playersSelection = value; }
        }

        //Begin Methods:

        public void BuyStuff()
        {
            while (PlayersSelection != 21)
            {    
                Console.Clear();
                Console.WriteLine("What would you like to buy:(type 22 to exit)");
                int list = 1;
                    for (int index = 0; index < itemsForSale.Length; index++)
                    {
                        Console.WriteLine(list + ". " + itemsForSale[index] + " costs $" + pricesForItems[index]);
                        ++list;
                    }
                playersSelection = Convert.ToInt32(Console.ReadLine()) - 1;

                if (PlayersSelection == 21)
                    {
                        break;
                    }

                else if (PlayersInventory.Length == placeItemInIndexOfPlayersInventory)
                    {
                        Console.Clear();
                        Console.WriteLine("You cannot carry any more objects");
                        Console.ReadLine();
                        break;
                    }

                else if (PlayersMoney < PricesForItems[playersSelection]) 
                    {
                        Console.Clear();
                        Console.WriteLine("\nYou do not have enough money");
                        Console.ReadLine();
                        continue;
                    }
                else
                    {
                        PlayersInventory[placeItemInIndexOfPlayersInventory] = itemsForSale[playersSelection];
                        PlayersInventoryIndex[placeItemInIndexOfPlayersInventory] = PlayersSelection;
                        ++placeItemInIndexOfPlayersInventory;
                        PlayersMoney -= PricesForItems[playersSelection];

                        Console.WriteLine("You just bought a/n " + itemsForSale[playersSelection] + " for $" + pricesForItems[playersSelection]);
                        Console.WriteLine("You have $" + PlayersMoney + " left.");
                        Console.ReadLine();
                    }                
            }
        }
    }
}

List Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuySell_Gear
{
    class List
    {
        public void GenerateList()
        {
            Buy buy = new Buy();
            Console.Clear();
            int list = 1;
            for (int index = 0; index < buy.PlayersInventory.Length; index++)
            {
                if (buy.PlayersInventory[index] == null)
                {
                    Console.WriteLine(list + ". empty");
                    ++list;
                    continue;
                }
                else
                {
                    Console.WriteLine(list + ". " + buy.PlayersInventory[index]);
                    ++list;
                }
            }
            Console.ReadLine();
        }
    }
}

 




PARTNERS