Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dodger Game in C# Pin
Qobacha27-Apr-12 9:26
Qobacha27-Apr-12 9:26 
GeneralRe: Dodger Game in C# Pin
Eddy Vluggen27-Apr-12 9:45
professionalEddy Vluggen27-Apr-12 9:45 
GeneralGame in C# Pin
Qobacha29-Apr-12 9:26
Qobacha29-Apr-12 9:26 
AnswerRe: Game in C# Pin
Eddy Vluggen30-Apr-12 0:59
professionalEddy Vluggen30-Apr-12 0:59 
GeneralRe: Game in C# Pin
Qobacha30-Apr-12 20:38
Qobacha30-Apr-12 20:38 
GeneralRe: Game in C# Pin
Qobacha1-May-12 2:16
Qobacha1-May-12 2:16 
AnswerRe: Game in C# Pin
Eddy Vluggen1-May-12 8:45
professionalEddy Vluggen1-May-12 8:45 
GeneralRe: Game in C# Pin
Qobacha1-May-12 12:50
Qobacha1-May-12 12:50 
Before I could give up what do you think of this attempt. Making new method to check the position of the ball against the player?
Here is my attempt not sure if it will work though.

private bool collision(Player player)
{
return !(player.x > x + radius
|| player.x + 30 < x
|| player.y > y + radius
|| player.y + 30 < y);
}

C#
namespace MyFirstGameTutorial
{
    public class Ball
    {
        Player square;
        public float x, y, yvel, radius;
        public Brush brush;
        public Ball(int gamewidth,int gameHeight,Random r)        

        {
           
            x = r.Next(gamewidth);
            y = r.Next(gameHeight);

            yvel = r.Next(2) + 2;

            radius = r.Next(10) + 5;
            brush = new SolidBrush(Color.Blue);
            
        }
      
        public void Move(int gameHeight)
                       
        {                
            if (y + radius >= gameHeight)
            {
                y =  0;      
                
            }
           y += yvel;


           
           /* if(yvel > gameHeight && collision(square))
            {
                MessageBox.show("Collision Detected");
            }         
            y += yvel;*/
        }


        public void Draw(Graphics g)
        {
            RectangleF circle = new RectangleF(x - radius, y - radius, radius * 2, radius * 2);
            //g.FillEllipse(brush, new RectangleF(x-radius,y - radius, radius * 2, radius * 2));
            g.FillEllipse(brush, circle);
        }

        
      private bool collision(Player player)
        {
            return !(player.x > x + radius
                    || player.x + 30 < x
                    || player.y > y + radius
                   || player.y + 30 < y);
        }
        
    }
}

GeneralRe: Game in C# Pin
Eddy Vluggen2-May-12 6:47
professionalEddy Vluggen2-May-12 6:47 
AnswerRe: Dodger Game in C# Pin
Abhinav S19-Apr-12 16:28
Abhinav S19-Apr-12 16:28 
GeneralRe: Dodger Game in C# Pin
CDP180220-Apr-12 4:03
CDP180220-Apr-12 4:03 
GeneralRe: Dodger Game in C# Pin
Qobacha20-Apr-12 10:52
Qobacha20-Apr-12 10:52 
GeneralRe: Dodger Game in C# Pin
Qobacha20-Apr-12 10:51
Qobacha20-Apr-12 10:51 
QuestionMenuStrip Erroneously Closing Pin
Skippums19-Apr-12 7:27
Skippums19-Apr-12 7:27 
AnswerRe: MenuStrip Erroneously Closing Pin
Alan N19-Apr-12 10:05
Alan N19-Apr-12 10:05 
GeneralRe: MenuStrip Erroneously Closing Pin
Skippums19-Apr-12 10:46
Skippums19-Apr-12 10:46 
QuestionJust a C# application. Pin
amx_tiger19-Apr-12 6:17
amx_tiger19-Apr-12 6:17 
AnswerRe: Just a C# application. Pin
Eddy Vluggen19-Apr-12 9:46
professionalEddy Vluggen19-Apr-12 9:46 
GeneralRe: Just a C# application. Pin
amx_tiger19-Apr-12 10:26
amx_tiger19-Apr-12 10:26 
AnswerRe: Just a C# application. Pin
Eddy Vluggen19-Apr-12 11:02
professionalEddy Vluggen19-Apr-12 11:02 
GeneralRe: Just a C# application. Pin
amx_tiger19-Apr-12 20:08
amx_tiger19-Apr-12 20:08 
GeneralRe: Just a C# application. Pin
Sentenryu20-Apr-12 1:29
Sentenryu20-Apr-12 1:29 
GeneralRe: Just a C# application. Pin
amx_tiger20-Apr-12 4:52
amx_tiger20-Apr-12 4:52 
QuestionProblems deploying Soap MTOM service WCF with Java Client Pin
sfinxrecord1319-Apr-12 5:10
sfinxrecord1319-Apr-12 5:10 
Questionappalication development Pin
ramnath_k19-Apr-12 4:37
ramnath_k19-Apr-12 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.