c# game

Started by
48 comments, last by phil67rpg 5 years, 3 months ago

I  have done pong and tic tac toe in c# I was thinking about doing blackjack next, do you think this is a good next game?

Advertisement

It's definitely a bit of a step up in complexity, do you enjoy playing Black Jack?  If so, well then go for it!  It seems like an easy enough game to break down.  Probably even easier than Solitaire, for overall game complexity anyhow.  If you want to work on a card game next, then I suppose it's most important to pick one you enjoy and understand fairly well, if Black Jack fits that description for you then awesome.  ;)

ok well then I will pursue it, only  one problem is how do I set it up, there is a lot flexibility in the design.

It's your game, pick a direction and try it out. ;)  Have fun with it.

Sounds good to me too. You can definitely learn a few useful data structures, etc. on a card game.

Developer since 1994. Programming since '80. Still like it.

I have a simple question I am trying to draw a bitmap to the screen. here is the code I am using I am getting a parameter is not valid error.


        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            Bitmap bitmap = new Bitmap("c01.bmp");
            g.DrawImage(bitmap, 20, 20);
            g.Dispose();
        }

 

Not in a position to test this just now but you should use the Graphics from the paint event, i.e. e.Graphics

edits:

https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/how-to-draw-an-existing-bitmap-to-the-screen

And don't dispose of the Graphics in this case. But if you did, you could wrap the code in a using() statement instead.

Also, showing the error message would be very helpful :)

Developer since 1994. Programming since '80. Still like it.

the error is "Parameter is not valid" here is my adjusted code


        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Bitmap bitmap = new Bitmap("c01.bmp",true);
            g.DrawImage(bitmap, 20, 20);
        }

 

 

3 minutes ago, phil67rpg said:

the error is "Parameter is not valid" here is my adjusted code



        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Bitmap bitmap = new Bitmap("c01.bmp",true);
            g.DrawImage(bitmap, 20, 20);
        }

 

 

I meant if you could somehow copy & paste the actual, full error message/stack trace (it must be a runtime error).

Does c01.bmp exist? Can it be located by the app?

Developer since 1994. Programming since '80. Still like it.

This topic is closed to new replies.

Advertisement