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

Recommended Answers

All 7 Replies

Hi there! It seems like you've got all the complicated stuff working. Graphics! Interactive players! Flying tokens! It sounds to me like a little timer to end the level is simple stuff.

So now as far as posting the code for the timer so that we can take a look at it and hopefully help you debug it ... I'm really, really sorry you've been having a difficult time posting on DaniWeb. It sounds to me like you are encountering a bug.

Are you clicking on the little Code button in the editor toolbar and inserting the code into your post that way? Can you attach to your post a screenshot of what isn't working?

I'd really appreciate your help in debugging this, in case it ends up being a bug on my end. Thanks so much.

Also, I just want to confirm you aren't creating a new "Code Snippet" because that's only for fully working code snippets, not to post code that isn't working.

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";
            }
        }

In what way do you need help with the code? Does it not work as expected? From the very little you posted, it doesn’t seem to make much sense to me.

Where do you create the musicplayer object? Why are you closing it and then setting a URL?

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 < 900)
                {
                    snoopy.Left += pc.pmove;
                }
            }
            if (left == true)
            {
                if (snoopy.Left > 12)
                {
                    snoopy.Left -= pc.pmove;
                }
            }
            if (up == true)
            {
                if (snoopy.Top > 30)
                {
                    snoopy.Top -= pc.pmove;
                }
            }
            if (down == true)
            {//put picture boundaries here
                if (snoopy.Top < 625)
                {
                    snoopy.Top += pc.pmove;

                }
            }
        }
        void GameAction()
        {
            //Here Snoopy has to touch Woodstock and when he does he gets points
            foreach(Control a in this.Controls)
            {
                if(a is PictureBox && a .Tag == "woodstock")
                {
                    pc.points++;//player earns 1 point each time Snoopy touches Woodstock
                }
            }
        }
        //This was my last attempt
        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";
            }
        }
        private void GameTimer_Tick(object sender, EventArgs e)
        {
            SnoopyMovement();

        }
    }
}

You're doing a really good job, but it's probably too hard to develop.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.