Onion13 31 Junior Poster in Training

So I had to get a new hard drive for my laptop and when I installed visual studios 2022 I noticed that Data Sources was missing everything. I took a screen shot to perhaps explain it better to you guys. I've tried looking online how to restore it and can't find how to restore it. Can someone help me?

visual_studio1.PNG

Onion13 31 Junior Poster in Training

I found what the problem was in the program. I put an incorrect path to the songs and once I corrected that mistake it worked like a charm.

Onion13 31 Junior Poster in Training

Can you give me some examples or a link? I am using visual studio on a windows computer.

rproffitt commented: Sorry but there are so many versions of Visual Studio. If the above didn't compile, could be a setup issue. +16
Onion13 31 Junior Poster in Training

When I run it on visual studio it runs but music doesn't play. I don't get any error messages. When I use the same program on my other laptop without the windows update it runs perfectly and plays music.

Onion13 31 Junior Poster in Training

My program worked earlier this year before Windows 10 put and update and suddenly it doesn't work anymore. I have a separate laptop that didn't get the update and it works perfectly. Can someone please tell me what I need to do to get it to work? Ive tried everything I could think of and nothing works.

                    string[] music = Directory.GetFiles(@"C:\Users\Robert\Documents\C# stuff\Skynet\Skynet\bin\Debug\Music file", "*.mp3");// this is the original path

                    WMPLib.IWMPPlaylist Classicalplaylist = mplayer.playlistCollection.newPlaylist("classicalplaylist");
                    foreach (string file in music)
                    {
                        WMPLib.IWMPMedia media = mplayer.newMedia(file);
                        Classicalplaylist.appendItem(media);
                    }
                    mplayer.currentPlaylist = Classicalplaylist;
HuiCheng commented: i think you Pc audio have program,my windows 11 can start,is you audio have program? +0
Onion13 31 Junior Poster in Training

I finished my course C# on Cloud Academy and thought this would be an easy project to do. I looked online and couldn't find anything remotely as a suggestion to help me. Would you please help me? I really wanted to get it done before her birthday.

Onion13 31 Junior Poster in Training

That was my latest attempt to make a background music player for the game. My plan is to have 3 levels for the game and each level will play a song. I have tried previously to use a stopwatch, a for loop but neither worked. I thought maybe this last idea would work.

This is the whole code up to now. I haven't continued further because I wanted to get the music part and the 3 levels to work. I created a player class for Snoopy that controls the speed he flies in the game.

Ive included the entire game below.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Snoopy_game
{
    public partial class Form1 : Form
    {
        bool up, down, left, right;
        public int _ticks;
        playerclass pc = new playerclass();
        public Form1()
        {
            InitializeComponent();
            musicplayer.Visible = false;

        }
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                right = true;
            }
            if (e.KeyCode == Keys.Left)
            {
                left = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                up = true;
            }
            if (e.KeyCode == Keys.Down)
            {
                down = true;
            }
        }
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Right)
            {
                right = false;
            }
            if (e.KeyCode == Keys.Left)
            {
                left = false;
            }
            if (e.KeyCode == Keys.Up)
            {
                up = false;
            }
            if (e.KeyCode == Keys.Down)
            {
                down = false;
            }
        }
        void SnoopyMovement()
        {
            if (right == true)
            {
                if (snoopy.Left < …
Onion13 31 Junior Poster in Training

Sorry it took me so long to get back to you. I read your comment and I wasn't sure if you wanted me to post the entire code or the part I needed help. I'm guessing you wanted me to post the part I needed help. I've included it below.

My plan was to have a song play over and over till the player collects n number of Woodstocks, then it will switch to a mini intermission which will be Snoopy dancing and then after that short dance, the next level will start. In total there will be 3 levels and each level will play a different song. I haven't gotten to that point (Snoopy dancing) because I wanted to get the levels working then move to the next part.

        void GameMusic()
        {
            //The player has 5 min to catch as many Woodstocks as they can
            //level 1 will play the Peanuts theme
            //level 2 will play the song Snoopy
            //level 3 will play flash beagle
            _ticks++;
            if(_ticks < 50000)
            {
                musicplayer.URL = "Peanuts theme.mp3";
            }
            else
            {
                musicplayer.close();
                musicplayer.URL = "Snoopy dance.mp3";
            }
        }
Onion13 31 Junior Poster in Training

Working on a game for a friends daughter for her 6th birthday. Its a scrolling game where the player will be Snoopy and they'll be flying around on his doghouse collecting Woodstock (Which are flying around the screen) for each level (There will be 4 levels). At the end of each level, the game will have an intermission and show a 10sec video of Snoopy dancing. The background will play the Peanuts theme song. Ive figured out everything except how to make levels for the game. I've tried using a timer but that didn't seem to work very well. Everytime Ive tried to include the block of code I've written the screen doesn't add it and returns back to step one of asking a question on this forum.

KevinYoung commented: You are trying to make a great game, but it's true that it's missing something about the level, you can look up more on the internet for similar games +0
Onion13 31 Junior Poster in Training

Making a scrolling space shooting video game in C# where the player will fight one on one with their opponent. I was able to figure out how to make the missile go up if the opponent was above the player. But, I can't seem to make it work if the opponent is below or right infront of the player. Can someone help me? I know the answer is right under my nose.

The function below handles the movement of the missile

 void movemissile()
        {
            foreach (Control y in this.Controls)
            {
                if (y is PictureBox && y.Tag == "missile") 
                {

                    //y.Left += 100;//x.Top -= 10;
                    if (y.Left > enemy.Left)//<100
                    {
                        y.Left += 10;
                        //this.Controls.Remove(y);
                    }

                    //plyer missile goes up if opponent is above
                    if (y.Top > enemy.Top)
                    {
                        y.Left += 10;
                        y.Top -= 20;
                        y.Left += 10;
                        //this.Controls.Remove(y);
                    }
                    y.Left += 100;//x.Top -= 10;
                    if (y.Top > enemy.Left)//<100
                    { 
                        this.Controls.Remove(y);
                    }
                }
            }
        }

        This function handles drawing the missile of the player for the game.
                void Missile()
        {
            PictureBox m = new PictureBox();
            m.SizeMode = PictureBoxSizeMode.AutoSize;
            m.Image = Properties.Resources.Missile1;
            m.BackColor = System.Drawing.Color.Transparent;
            m.Tag = "missile";
            m.Left = Player.Left + 100;//moves bullet left or right
            m.Top = Player.Top + 55;//55 is perfect
            this.Controls.Add(m);
            m.BringToFront();
        }
Onion13 31 Junior Poster in Training

Disregard my previous post. I figured it out after staying up all night.

Onion13 31 Junior Poster in Training

I kind of figured out how to put a pause in my 2d game when the player shoots. The problem is that when the player shoots once, the game will continue to shoot continously, even after the player has stopped shooting. Can someone please help me?

        void Bullet()//draws the players ship ammo
        {
            PictureBox bullet = new PictureBox();
            bullet.SizeMode = PictureBoxSizeMode.AutoSize;
            bullet.Image = Properties.Resources.Shoot;
            bullet.BackColor = System.Drawing.Color.Transparent;
            bullet.Tag = "bullet";
            bullet.Left = playersuper.Left + 100;//moves bullet left or right
            bullet.Top = playersuper.Top + 50;//55 is perfect                    
            this.Controls.Add(bullet);
            bullet.BringToFront();
            shootimer.Interval = 1000;
            shootimer.Enabled = true;
        }
         private void shootimer_Tick(object sender, EventArgs e)
        {
            fire = new SoundPlayer("shooting.wav");
            fire.Play();
        }
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            bool playing = false;
            if (e.KeyCode == Keys.Right)
            {
                right = true;
            }
            if (e.KeyCode == Keys.Left)
            {
                left = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                up = true;
            }
            if (e.KeyCode == Keys.Down)
            {
                down = true;
            }
            if (e.KeyCode == Keys.Space)
            {
                Bullet();
            }
            if (e.KeyCode == Keys.A)
            {
                if (nomissiles.Value >= 10)
                {
                    pc.miss--;
                    nomissiles.Value -= 10;
                    A = true;
                    Missile();
                }
            }
            if (e.KeyCode == Keys.Z)
            {
                PictureBox robot = new PictureBox();
                robot.SizeMode = PictureBoxSizeMode.AutoSize;
                robot.Image = Properties.Resources.Bioroidd;
                robot.BackColor = System.Drawing.Color.Transparent;
                ((PictureBox)playersuper).Image = Properties.Resources.Bioroidd;
                transform = new SoundPlayer("transforming.wav");
                transform.Play();
            }
            if (e.KeyCode == Keys.X)
            {
                PictureBox gerwalk = new PictureBox();
                gerwalk.SizeMode = PictureBoxSizeMode.AutoSize;
                gerwalk.Image = Properties.Resources.Gurwalk;
                gerwalk.BackColor = System.Drawing.Color.Transparent;
                ((PictureBox)playersuper).Image = Properties.Resources.Gurwalk;
                transform = new SoundPlayer("transforming.wav");
                transform.Play();
            }
            if (e.KeyCode == Keys.C)
            {
                PictureBox fighter = new PictureBox();
                fighter.SizeMode …
Onion13 31 Junior Poster in Training

That helped but I was looking for a way for the images to move on their own. I'll try to modify the example given from your link and see if I can make it work.

Onion13 31 Junior Poster in Training

Working on a game and I made a separate class to handle the players enemies (Its a scrolling type 90s game). I know if I use picturebox and put it on form1 I can say for example....
enemy1.Left > 90;
My question is how would I do something like that with bitmap? I figured out how to put the image on form1, but I can't figure out how to make it move.

Onion13 31 Junior Poster in Training

Would someone explain to me how to use bitmap. I have a video game I am working on so I added images using resourcesrx and wanted to use bitmap to display where they will appear on form1. I saved the image as player.

Onion13 31 Junior Poster in Training

Made progress on my game and now I need to make the second boss bounce up and down. I figured out how to make the boss go down, but once it touches the lower wall, it stops and won't bounce (move up).

        void BossMove()
        {
            if((BOSS.Top + 10) <(this.Height - BOSS.Height))
            {
                BOSS.Top += 10;
            }
            if((BOSS.Height) > 0)
            {
                BOSS.Top -= 10;
            }
        }
Onion13 31 Junior Poster in Training

Working on a video game using visual studio and I am having trouble with the sound effect when the player shoots their weapon. When the player shoots multiple times, the sound overlaps. Ive tried many things and this was my last attempt. Can someone please help me? I am stuck.

if (e.KeyCode == Keys.Space)
            {
                while(true)
                {
                    bossTimer.Stop();
                    space = true;
                    Bullet();
                    fire = new SoundPlayer("shooting.wav");
                    fire.Play();
                    bossTimer.Start();
                }

Below is my program

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace boss_fight
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        bool right, left, up, down, space, A;
        int miss = 10;//number of missiles

        void HitorMiss()
        {
            foreach (Control j in this.Controls)
            {
                foreach (Control i in this.Controls)
                {
                    if (j is PictureBox && j.Tag == "shot" || j is PictureBox && j.Tag == "missile")
                    {
                        if (i is PictureBox && i.Tag == "boss")
                        {
                            if(j.Bounds.IntersectsWith(i.Bounds))
                            {

                                if (enemyhealth.Value == 0)
                                {
                                    PictureBox bullet = new PictureBox();
                                    bullet.SizeMode = PictureBoxSizeMode.AutoSize;
                                    bullet.Image = Properties.Resources.Shoot;
                                    bullet.BackColor = System.Drawing.Color.Transparent;
                                    ((PictureBox)j).Image = Properties.Resources.explosion;
                                }
                                else
                                    enemyhealth.Value -= 10;
                            }
                        } 
                    }
                }
                if (Player.Bounds.IntersectsWith(e1laser.Bounds))//Player loses health when hit by boss laser
                {
                    if (healthbar.Value == 0)
                    {
                        PictureBox bullet = new PictureBox();
                        bullet.SizeMode = PictureBoxSizeMode.AutoSize;
                        bullet.Image = Properties.Resources.Shoot;
                        bullet.BackColor = System.Drawing.Color.Transparent;
                        ((PictureBox)Player).Image = Properties.Resources.explosion;
                    }
                    else
                        healthbar.Value -= 10;
                }
            }
        }
        void Shot()//positions where players laser shows on the screen
        {
            PictureBox ammo = new PictureBox();
            ammo.SizeMode = …
Onion13 31 Junior Poster in Training

I figured it out. The answer was right in front of my eyes and I didn't see it. Thank you for your help.

Onion13 31 Junior Poster in Training

I did what you suggested and nothing appears. When I run through the lines of code I have a red line below line 45 Text.

What I am trying to do here is dynamicaly create the number of labels needed to display the string elements in the list and then display them in form1. How do I do that and am I on the right track?

Onion13 31 Junior Poster in Training

Tryng to work on a program to make a menu on form1. What it will do is display the different things offered at the restaurant and the text will scrolll from the bottom of the screen to the top and then repeat.

I was able to figure out how to make labels dynamically but I can't figure out how to display them on form1.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace cafeteka_mod1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int fav = 9;

        void allamerican()
        {
            Label[] labels = new Label[fav];

            for(int i = 0; i < fav; i++)
            {
                labels[i] = new Label();
            }
            for(int a = 0; a < fav; a++)
            {
                this.Controls.Add(labels[a]);
            }
            string[] one = { "ALL AMERICAN FAVOURITES","Cafe Americano... $35",
            "Capuccino... $40",
            "Cafe Latta... $40",
            "Macchiato... $50",
            "Mocha... $40",
            "Mocha Blanco... $50",
            "Espresso... $30",
            "Mocha Organico... $60",
            "Cold Brew... $50"};

            for(int y = 0; y < fav; y++)
            {
                labels.Text = one.ToString();
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {

        }
    }
}
Onion13 31 Junior Poster in Training

I did what you suggested and honestly I just don't see it. I broke that function down to the basics, took out the extra features and only left the code which shows the boss blowing up and after the player defeats the boss, the player is frozen in place. I checked my entire code ine per line and didn't see anywhere that the game timer was stoped.

Onion13 31 Junior Poster in Training

I did what you suggested and tried to do the same thing I have for next level that I have on new game and it still doesn't work. Do you have any other ideas? I'm really stuck

rproffitt commented: That item was the only item that stuck out to me. Again, look for what's different from a new board to this nextlevel. +15
Onion13 31 Junior Poster in Training

Sorry, I thought you needed the whole code. Ok Ill break it down to show what part I'm stuck on in the program.

This is part of the function which handles when the boss is hit by the player laser and what happens when the boss dies. It also calls 3 functions
GameScore();//as game plays the players score increases
GameLevel();// will show what level the player is on
NextLevel();//Which puts all of the enemies randomly on the far right of the screen

if (i is PictureBox && i.Tag == "boss")
                        {
                            if (j.Bounds.IntersectsWith(i.Bounds))
                            {
                                if (enemyhealth.Value <= 0)
                                {
                                    i.Top = -750;
                                    mplayer.close();
                                    PictureBox shoot = new PictureBox();
                                    shoot.SizeMode = PictureBoxSizeMode.AutoSize;
                                    shoot.Image = Properties.Resources.Shoot;
                                    shoot.BackColor = System.Drawing.Color.Transparent;
                                    ((PictureBox)j).Image = Properties.Resources.explosion;
                                    nomissiles.Value = 100;
                                    healthbar.Value = 100;
                                    nomissiles.Value = 100;
                                    healthbar.Value = 100;
                                    playersuper.Location = new Point(0, 250);
                                    PictureBox fighter = new PictureBox();
                                    fighter.SizeMode = PictureBoxSizeMode.StretchImage;
                                    fighter.Image = Properties.Resources.fighter;
                                    fighter.BackColor = System.Drawing.Color.Transparent;
                                    ((PictureBox)playersuper).Image = Properties.Resources.fighter;
                                    transform = new SoundPlayer("transforming.wav");
                                    transform.Play();
                                    nmissiles.Visible = false;
                                    healthup.Visible = false;
                                    enemyhealth.Visible = false;
                                    lblbosshealth.Visible = false;
                                    victory = new SoundPlayer("victory.wav");
                                    victory.Play();
                                    fly.URL = "gundam_soaring_by.mp3";
                                    fly.controls.play();
                                    nomissiles.Value = 100;
                                    healthbar.Value = 100;
                                    nomissiles.Value = 100;
                                    healthbar.Value = 100;
                                    GameScore();//as game plays the players score increases
                                    GameLevel();// will show what level the player is on
                                    powerarmour.Visible = false;
                                    e9laser.Visible = false;
                                    powerarmour.Location = new Point(-250, -50);//
                                    e9laser.Location = new Point(-150, 50);  //(1250,50);
                                    boom.Visible = false;
                                    boom1.Visible = false;
                                    boom2.Visible = false;
                                    boom3.Visible = false;
                                    boom4.Visible = false;
                                    boom5.Visible = false;
                                    lblyoukilled.Visible = true;
                                    lblkilled.Visible = true;
                                    lblenemies.Visible …
Onion13 31 Junior Poster in Training

Learning C# and I am working on a C# scrolling shooting game. The game works so far but when the player finishes a level, I want the enemies to appear on the far right of the screen and the player on the left of the screen. When the level is finished neither the enemies or the player appear. Can someone please help me?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
using WMPLib;
namespace Macross_mod_8
{
    public partial class Game : Form
    {
        WindowsMediaPlayer win = new WindowsMediaPlayer();
        WindowsMediaPlayer Roy = new WindowsMediaPlayer();
        WindowsMediaPlayer Rick = new WindowsMediaPlayer();
        WindowsMediaPlayer squad = new WindowsMediaPlayer();
        WindowsMediaPlayer alien = new WindowsMediaPlayer();
        WindowsMediaPlayer fly = new WindowsMediaPlayer();
        playerclass pc = new playerclass();
        LevelClass lc = new LevelClass();
        private SoundPlayer pl = new SoundPlayer();
        private SoundPlayer fire;
        private SoundPlayer transform;
        private SoundPlayer victory;
        //private SoundPlayer dead;
        private SoundPlayer theme = new SoundPlayer();
        int num = 0;//used to count images for imagelist
        int no = 0;//used to count images for imagelist
        bool right, left, up, down, space, Z, X, C, A;
        int score;//this will run as long as the player has lives and doesn't die
        int fscore;
        int kills;//how many enemies player killed in the game
        int miss = 10;// number of missiles player has
        int m = 0;//Counts how many missiles have been used by the player
        int i = 0;//used for healing square
        int xp = 0;//number used to count for explosions …
Onion13 31 Junior Poster in Training

I made a snippet for that part of the game using idea of just making a picturebox appear after 10 seconds. In the game it will appear once the player finishes that level.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
namespace vanishing_picturebox
{
    public partial class Form1 : Form
    {

        System.Timers.Timer timer;
        DateTime myLimit;
        public Form1()
        {
            InitializeComponent();
        }
        void Pic()
        {

            timer = new System.Timers.Timer();
            timer.Interval = 1000;
            timer.Elapsed += timer1_Tick;

            DateTime presenttime = DateTime.Now;
            DateTime vanish = myLimit.AddSeconds(1000);//AddMinutes(5);

            if (DateTime.Now > vanish)
            {
                pictureBox1.Visible = false;
            }
            else
                pictureBox1.Visible = true;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {

            Pic();

        }
    }
}
Onion13 31 Junior Poster in Training

Making a scrolling game and I want to make a boss level. How do I make a picturebox invisible for 10 seconds and then appear?

Onion13 31 Junior Poster in Training

How do you call a constructor to initialize a variable using form1?

Onion13 31 Junior Poster in Training

I made some progress on the problem and can make the picturebox disappear till I need it to appear. The problem I have is now the picturebox will flickers for a moment showing the picturebox then disappears. How do I make it just appear?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;
using System.Diagnostics;


namespace game
{
    public partial class Game : Form
    {

        System.Timers.Timer timer;
        public Game()
        {
            InitializeComponent();
        }

        bool right, left, up, down, space, A;
        //int Plives = 3;//player lives in game
        int score;
        int p = 0;
        int i = 0;
        int m = 0;
        playerclass pc = new playerclass();
        int miss = 10;//number of missiles

        void start()
        {
            lblgameover.Visible = false;
            powerarmour.Visible = false;
        }


        void Lives()
        {
            if (pc.Plives > 0)
                pc.Plives -=1;
            if (pc.Plives == 3)
            {
                life1.Visible = true;
                life2.Visible = true;
                life3.Visible = true;
            }
            else if (pc.Plives == 2)
            {
                life1.Visible = false;
                life2.Visible = true;
                life3.Visible = true;
            }
            else if (pc.Plives == 1)
            {
                life1.Visible = false;
                life2.Visible = false;
                life3.Visible = true;
            }
            else if (pc.Plives == 0)
            {
                life1.Visible = false;
                life2.Visible = false;
                life3.Visible = false;
            }
        }
        void AddMissiles()
        {
            Random addmiss = new Random();
            m++;
            int mi;
            nmissiles.Left -= 10;
            if(m == 150 && nmissiles.Left < 0)
            {
                mi = addmiss.Next(50, 500);
                nmissiles.Location = new Point(1200, mi);
            }
            if (m == 500)
                m = 0;
        }
        void Health()
        {
            Random hpup …
Onion13 31 Junior Poster in Training

I am learning to code and I have been working on a game using what I have learned to make it. So I have been making my version of R type C# game and got everything working so far but I run out of ideas how to make this part of the game work.

I wanted to make the boss appear after 5 min of game play and have the smaller opponents disappear. The boss was going to bounce around the screen like a Windows screen saver till the player destroys it (I know how to do that part since I made a pyame do that). The problem is that I can't figure out how to make the boss disappear till the 5min mark and then reappear.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace game
{
    public partial class Game : Form
    {
        public Game()
        {
            InitializeComponent();
        }
        bool right, left, up, down, space, A;
        //int Plives = 3;//player lives in game
        int score;
        int p = 0;
        int i = 0;
        playerclass pc = new playerclass();
        int miss = 10;//number of missiles

        void start()
        {
            lblgameover.Visible = false;
            powerarmour.Visible = false;
        }


        void Lives()
        {
            if (pc.Plives > 0)
                pc.Plives -=1;
            if (pc.Plives == 3)
            {
                life1.Visible = true;
                life2.Visible = true;
                life3.Visible = true;
            }
            else if (pc.Plives == 2)
            {
                life1.Visible = false;
                life2.Visible = true;
                life3.Visible = true;
            }
            else if (pc.Plives == …
Onion13 31 Junior Poster in Training

Yes, I'm sorry I thought I mentioned that in my question. I am trying to make a scrolling type video game and I figured out how to animate the missile and have it moe forward but I can't figure out how to make it a homing missile. There will be 7 enemies in the game and I was going to have a random choose which enemy it will seek out. Which I figured out for the game. So far, I only put 3 enemies because I wanted to start small, figure it out and then add enemies once I figure out how to make the homing missing work. As you can see its far from complete.

This is a snippet of the program I am working on.

void movemissile()
        {
            Random enemy = new Random();
            int ene;
            ene = enemy.Next(1, 5);
            foreach (Control y in this.Controls)
            {
                if (y is PictureBox && y.Tag == "missile")
                {
                    y.Left += 100;//x.Top -= 10;
                    if (y.Top > 900)//<100
                    {
                        this.Controls.Remove(y);
                    }
                }
            }
        }
Onion13 31 Junior Poster in Training

I've found many tutorials online for unity making homing missiles. I can't find one for people not using unity.

Onion13 31 Junior Poster in Training

Trying to make a game where explosions randomly appear on the screen using visual studio. I figured out how to make a single picture change location on the screen. So, I wanted to make the illusion of an explosion using imagelist. When I try to do it I get an error on my visual studio when I try to use Location. Location is underlined and say the following "ImageList" does not contain a definition for "Location" and no accessible extension method "Location" accepting a first argument of type "ImageList" could be found (Are you missing a using directive or an assembly reference?) I wanted to add more explosions on the screen .

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace random_image
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int num = 0;
        void Randompics()
        {
            int a;
            Random rnd = new Random();
            a = rnd.Next(30, 450);
            boom.Location = new Point(500, a);
        }
        void Explosions()
        {
            /*
            int a;
            Random rnd = new Random();
            a = rnd.Next(30, 450);
            symbol.Location = new Point(500, a);
            */
            Random rnd = new Random();
            int a;
            int x = rnd.Next(0, 800);
            int y = rnd.Next(0, 500);
            imageList1.Location = new Point(x,y);
            boom.Image = imageList1.Images[num];
            if (num == imageList1.Images.Count - 1)
            {
                num = 0;
            }
            else
                num++;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            Explosions();
            //Randompics();
        }
    }
}
Onion13 31 Junior Poster in Training

Now I'm getting this error.

Traceback (most recent call last):
line 185, in <module>
    Game().run()
 line 11, in run
    next_start = self.Scenes[start].enter()
KeyError: 'scene_intro'
Onion13 31 Junior Poster in Training

I fixed that error but I still have an error but this time it says...

Traceback (most recent call last):
 line 180, in <module>
    Game().run()
   line 10, in run
    start = self.Scenes[start].enter()
KeyError: None

I know in theory my program would work and I know the problem is something I over looked.

Onion13 31 Junior Poster in Training

When I select to fight the alien I get the following error message:

Traceback (most recent call last):
line 180, in <module>
Game().run()
line 10, in run
start = self.Scenes[start].enter()
KeyError: <function scene_intro at 0x02C28D30>

Onion13 31 Junior Poster in Training

It didn't work. Do you have any other ideas?.

Onion13 31 Junior Poster in Training

Studying python and in the lesson it says to modify anc change the program. I thought I'd make the game more interactive. I know it requires the program to use inheritance and I've read everything and Ive tried everything. Ive run out of ideas and would appreciate any and all help. trying to make the game loop from the main class to the subclass where the player will fight against the aliens. When I try to make it loop to the submenu I keep getting the following error message.

This is the error I keep getting.
Traceback (most recent call last):

 in <module>
 Game().run()
 line 13, in run
 start = self.Scenes.get(start).enter()
AttributeError: 'NoneType' object has no attribute 'enter'

This is the program.
It stops right when I try and make it go to the submenu of the game.

import random
class Game(object):
    def __init__(self):
        self.Scenes={"Intro":Intro(),"CorridorRoom":CorridorRoom(),"EngineRoom":EngineRoom(),
                     "ArmouryRoom":ArmouryRoom(),"EscapePod":EscapePod(),
                     "Bridge":Bridge(),"scene":dead()}

    def run(self):
        start="Intro"
        while True:
            start = self.Scenes.get(start).enter()

class Scene(object):
    def enter(self):
        pass
        exit(0)

class State(Scene):        
    def state(self):
        pass
        exit(0)

class state(Game):
    def __init__(self):
        self.player_hp = 10
        self.chicken_hp = 10

def scene_intro(state):
    print "Player vs chicken...."
    print "Fight!!! "
    return "scene_initiative"


def scene_initiative(state):
    print"Lets see who attacks first "
    chicken, player = roll(6),roll(6)
    print "Chickens rolls",chicken
    print "Player rolls",player
    if chicken<player:
        print "Player wins initiative "
        raw_input()
        return scene_player
    elif player<chicken:
        print "Chicken wins initiative "
        raw_input()
        return scene_chicken
    else:
        print"Even numbers, lets start again..."
        raw_input()
        return scene_initiative

def scene_player(state):
    damage = roll(10)
    print "The chicken takes", damage, "points …
Onion13 31 Junior Poster in Training

You could also make it slowly print each string one by one as fast or as slowly as you want doing this program.

from time import sleep

def foo():
    print "Hello"
    sleep(.5)
    print "my"
    sleep(.5)
    print "name"
    sleep(.5)
    print "is"
    sleep(.5)
    print "Matia"
    sleep(.5)
    print "..."
    sleep(.5)

foo()
Onion13 31 Junior Poster in Training

Before you make any game using python or any programming language you need to first map out the game, how you want to make it look, the characters and the fight scenes. From there making an oop game with class should be easy.

Onion13 31 Junior Poster in Training

I looked over my program and searched online to see what you meant by remove the test from run(). Forgive my silly question but I am still learning python, but what did you mean by that?.

Onion13 31 Junior Poster in Training

I followed your advice, took a step back and realised I was making my program too complicated. I simplified it and now I have a new problem. When the options appear on the screen, anytime I select an option other than 'exit', it will dislay the choice and then any other letter, number, action will cause the program to scroll and not do anything. The only time it works is when I select 'exit'. This is what I have so far.

class Letters(object):
    def __init__(self):
        self.Menus={"MainMenu":MainMenu(),"MenuA":MenuA(),
                        "MenuB":MenuB(),"MenuC":MenuC()}#Different menus in program
    def run(self):
        start="MainMenu"
        while True:
            if start =="MainMenu":
                start = self.Menus.get(start).enter()

class Scene(object):

    def enter(self):
        pass
        exit(1)

class MainMenu(Scene):
    def enter(self):
        print "Select one of the options: \n1.MenuA\n2.MenuB\n3.Menuc\n4.exit "
        while True:
            choice=raw_input()
            choice=choice.lower()
            if choice=='1':
                return "MenuA"
            elif choice=='2':
                return "MenuB"
            elif choice=='3':
                return "MenuC"
            elif choice=="4":
                exit(1)
            else:
                print "Select one of the choices "
                return "MainMenu"

class MenuA(Scene):
    def enter(self):
        print "Select one of the options: \nMainmenu\nMenuB\nMenuC\nexit"
        while True:
            choice=raw_input()
            choice=choice.lower()
            if choice=="mainmenu":
                return "MainMenu"
            elif choice=="menub":
                return "MenuB"
            elif choice=="menuc":
                return "MenuC"
            elif choice=="exit":
                exit(1)
            else:
                print "Select one of the options "
                return "MenuA"
class MenuB(Scene):
    def enter(self):
        print "Select one of the options: \nMain Menu\nMenuA\nMenuC\nexit\n"
        while True:
            choice=raw_input()
            choice=choice.lower()
            if choice=="main menu":
                return "MenuMain"
            elif choice=="menua":
                return "MenuA"
            elif choice=="menuc":
                return "MenuC"
            elif choice=="exit":
                exit(1)
            else:
                print "Select one of the options "

class MenuC(Scene):
    def enter(self):
        print "Select one of the options: \nMainMenu\nMenuA\nMenuB\nexit\n"
        while True:
            choice=raw_input()
            choice=choice.lower()
            if choice=="main menu":
                return "MenuMain"
            elif choice=="menua": …
Onion13 31 Junior Poster in Training

Trying to simplify the program. I know many people try and make their program look fancy, so I tried to make it simpler and I figure the easier it is to read the easier it is to maneuver around it to correct or add things to it. I read your reply and I get how the current_scene is the variable and was changed.

This is what I have so far. I now get the following error messages.
line 82, in <module>Letters().run()
line 22, in run self.stuff()
TypeError: stuff() takes exactly 6 arguments (1 given)

class Letters(object):
    def __init__(self):
        self.Menus=None
        self.Choice=None
        self.Question=None
        self.MenuMain=None
        self.Amenu=None
        self.Bmenu=None
        self.Cmenu=None
        self.CurrentMenu=None

    def stuff(self,Menus,Amenu,Bmenu,Cmenu,CurrentMenu):
        self.Menus={"MainMenu":MainMenu(),"MenuA":MenuA(),
                    "MenuB":MenuB(),"MenuC":MenuC()}#Different menus in program
        self.Main={"MenuA\n","Menub\n","Menuc\n","ExitMenu\n"}#Display string for Main menu
        self.Amenu={"Main menu\n","Menub\n","Menuc\n","ExitMenu\n"}#Display string for menu a
        self.Bmenu={"Main menu\n","Menua\n","Menuc\n","ExitMenu\n"}#Display string for menu b
        self.Cmenu={"Main menu\n","Menua\n","Menub\n","ExitMenu\n"}#Display string for menu c
        self.CurrentMenu=MenuMain

    def run(self):
        self.stuff()
        while self.CurrentMenu:
            self.CurrentMenu()

class MainMenu(Letters):
    def enter(self):
        print "Select one of the options: {} ".format(Main)
        while True:
            choice=raw_input()
            if choice=='MenuA':
                return "MenuA"
            elif choice=='MenuB':
                return "MenuB"
            elif choice=='MenuC':
                return "MenuC"
            else:
                print "Select one of the choices "

class MenuA(Letters):
    def enter(self):
        print "Select one of the options: {} ".format(Amenu)
        while True:
            choice=raw_input()
            if choice=="MenuB":
                return "MenuB"
            elif choice=="MenuC":
                return "MenuC"
            elif choice=="Main Menu":
                return "MenuMmain"
            else:
                print "Select one of the options "

class MenuB(Letters):
    def enter(self):
        print "Select one of the options: {} ".format(Bmenu)
        while True:
            choice=raw_input()
            if choice=="Main Menu":
                return "MenuMain"
            elif choice=="MenuA":
                return "MenuA"
            elif choice=="MenuC":
                return "MenuC"
            else:
                print "Select one of …
Onion13 31 Junior Poster in Training

What I am trying to do is figure out lesson #43 of learn python the hard way. Zed wants us to make a game and I understand how oop works and how to make the game he wants me to create, but I can't figure out how he loops it from one class to another. SO I figured I'd take a step back and try and make my own looping oop menu similar to the one I made with functions so I could figure out how to do it. Ive seen different programmers use different ways to make it loop using a method and calling it 'run' or 'play'.

Onion13 31 Junior Poster in Training

Sorry it took so long to get back, I've been busy. I kept it re did the whole program and kept it simple. I didn't want to bite off too much before I figured how to make the oop program loop and I figure once I get the program to loop I can work on making it menu driven program. I can run it and it doesn't show any error messages, I've scoured the Internet for samples of other programmers work and they all have different ways to do it, but I can't find any tutorial on how they did it or why they chose that way to do it. Below is my program.

class Letters(object):
    def __init__(self):
        self.Menus=None
        self.Choice=None
        self.Question=None

    def stuff(self,Menus,Choice,Main,Amenu,Bmenu,Cmenu,question):
        self.Menus={"MainMenu":MainMenu(),"MenuA":MenuA(),
                    "MenuB":MenuB(),"MenuC":MenuC()}#Different menus in program
        self.Choice=Choice#used as a prompt
        self.Main={"MenuA\n","Menub\n","Menuc\n","ExitMenu\n"}#Display string for Main menu
        self.Amenu={"Main menu\n","Menub\n","Menuc\n","ExitMenu\n"}#Display string for menu a
        self.Bmenu={"Main menu\n","Menua\n","Menuc\n","ExitMenu\n"}#Display string for menu b
        self.Cmenu={"Main menu\n","Menua\n","Menub\n","ExitMenu\n"}#Display string for menu c
        self.question=("Selection an option ")

class MenuMain(Letters):
    def enter(self):
        while True:
            choice=raw_input("Select one of the options: {}\n".format(Main))
            if choice=='MenuA':
                return "MenuA"
            elif choice=='MenuB':
                return "MenuB"
            elif choice=='MenuC':
                return "MenuC"
            else:
                print "Select one of the choices "

class MenuA(Letters):
    def enter(self):
        while True:
            choice=raw_input("Select one of the options: {}\n".format(Amenu))
            if choice=="MenuB":
                return "MenuB"
            elif choice=="MenuC":
                return "MenuC"
            elif choice=="Main Menu":
                return "MenuMmain"
            else:
                print "Select one of the options "

class MenuB(Letters):
    def enter(self):
        while True:
            choice=raw_input("Select one of the options: {}\n".format(Bmenu))
            if choice=="Main Menu":
                return "MenuMain"
            elif choice=="MenuA":
                return "MenuA"
            elif choice=="MenuC":
                return "MenuC"
            else: …
Onion13 31 Junior Poster in Training

Right, right, duh I missed that in my haste to write the program. I have another question and I hope you can help me out with it. I've been learning python and I'm stuck on a lesson where I am suppose to create a game using oop (Which is why I tried to make that game I showed you using nothing but functions work into a oop program so I could get an idea what I was doing), I get how the whole thing works, but I cant wrap my head around the area where the program has a loop. I've tried to copy what other programmers have used to make their oop program work , but I can't seem to make mine work and I don't even know if I'm doing it correctly. Ive seen different programmers online use different methods to make it work, but I cant find a tutorial anywhere explaining how they came to that conclusion or samples of how to make it work. Would you be able to explain it to me using the program Ive been working on here in this website and please explain to me why you did that particular piece of code step by step?. The part I'm talking about is where I have the method with run in it.

def run(self):
        for s in self.Main:
            print s.enter() 
Onion13 31 Junior Poster in Training

Stuck with at how they make the oop program work.

Onion13 31 Junior Poster in Training

Right, right, duh I missed that in my haste to write the program. I have another question and I hope you can help me out with it. I've been learning python and I'm stuck on a lesson where I am suppose to create a game using oop (Which is why I tried to make that game I showed you using nothing but functions work into a oop program so I could get an idea what I was doing), I get how the whole thing works, but I cant wrap my head around the area where the program has a loop. I've tried to copy what other programmers have used to make their oop program work , but I can't seem to make mine work and I don't even know if I'm doing it correctly. Ive seen different programmers online use different methods to make it work, but I cant find a tutorial anywhere explaining how they came to that conclusion or samples of how to make it work. Would you be able to explain it to me using the program Ive been working on here in this website and please explain to me why you did that particular piece of code step by step?. The part I'm talking about is where I have the method with run in it.

Onion13 31 Junior Poster in Training

I get more or less how you did it, but I wanted to make it entirely using oop. I remade the program using just oop but when I try and run it I keep getting the following error message.
"self.menus=[mainMenu(),menua(),menub(),menuc(),submenua(),submenuc()]
TypeError: 'list' object is not callable"
How is it not callable if I have it defined in the constructor and I have a method for each menu? This is what I have so far.

mainMenu=['main menu','a','b','c','d','exit']
menua=['menua','apples','Amanda','alphabet','main menu','exit']
menub=['menub','banana','Betty','beagle','main menu','exit']
menuc=['menuc','chocolate','Cleo','cats','main menu','exit']
submenua=['green apples','red apples','main menu','back','exit']
submenuc=['porkchop','guera','scooter','houdini','main menu','back','exit']


class letters(object):
    def __init__(self,menus,choice):
        self.menus=[mainMenu(),menua(),menub(),menuc(),submenua(),submenuc()]
        self.choice=choice

    def Main(self):
        print "Select one of the options: {}\n".format(self.menus(mainMenu))
        for i in range(len(mainMenu)):
            print mainMenu[i]
            if choice =="menua":
                return menua
            elif choice =="menub":
                return menub
            elif choice =="menuc":
                return menuc
            elif choice =="exit":
                quit
            else:
                return Main
    def a(self):
        print menua

    def b(self):
        print menub

    def c(self):
        print menuc

    def suba(self):
        print submenuc

    def subc(self):
        print submenuc

    def run(self):
        for s in self.Main:
            print s.enter() 
Onion13 31 Junior Poster in Training

I was thinking of something similar to this this program.

main='a ,b ,c , exit,'
menua='apples, Amanda, alphabet, main menu, back, exit '
menub='banana, Betty, beagle, main menu, back, exit '
menuc='chocolate, Cleo, cats, main menu, back, exit '
submenua='green apples, red apples, main menu, back, exit '
submenuc='porkchop, guera, scooter, houdini, main menu, back, exit '
exit='leave'
def m():


    while True:
            choice=raw_input("Select one of the options: {} \n".format(main))
            choice=choice.lower()
            if choice=="a":
                    a()
            elif choice=="b":
                    b()
            elif choice=="c":
                    c()
            elif choice=="exit":
                    break


def a():
        while True:
                choice=raw_input("Select one of the options: {}\n ".format(menua))
                choice=choice.lower()
                if choice=="apples":
                        suba()
                elif choice=="amanda":
                        print"My friend Jinxy\n "
                elif choice=="alphabet":
                        print"The letters from A to Z\n "
                elif choice=="main menu":
                        m()
                elif choice=="exit":
                        leave()
                elif choice=="back":
                        break


def suba():
        while True:
                choice=raw_input("Select one of the options: {}\n".format(submenua))
                choice=choice.lower()
                if choice in ("red apples, red apple"):
                        print"You like red apples\n "
                elif choice in("green apples, green apple"):
                        print"You like green apples\n "
                elif choice=="main menu":
                        m()
                elif choice=="back":
                        break
                elif choice=="exit":
                        leave()
                else:
                        print"Please select from one of the options\n"

def b():
        while True:
                choice=raw_input("Select one of the options: {}\n ".format(menub))
                choice=choice.lower()
                if choice=="banana":
                        print "banana's are delicious\n "
                elif choice=="betty":
                        print "Short for Elizabeth\n "
                elif choice=="beagle":
                        print "Snoopy is a beagle\n "
                elif choice=="main menu":
                        m()
                elif choice=='back':
                        break
                elif choice=="exit":
                       leave()
                else:
                        print"Select one of the options"

def c():
        while True:
                choice=raw_input("Select one of the options: {}\n ".format(menuc))
                choice=choice.lower()
                if choice=="chocolate\n":
                        print "I'm a chocoholic\n "
                elif choice=="cleo":
                        print "Short for Cleopatra\n " …
Onion13 31 Junior Poster in Training

I've been learning python and I'm almost finished and I'm learning about oop. I have a question, is it possible to make a looping menu using oop on python (Not using Tkinter, WX) without having to key in the object. I learn better through playing around with what I've learned after I finished a lesson.