Jump to content
  • Advertisement
phil67rpg

c# game

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.  ;)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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();
        }

 

Share this post


Link to post
Share on other sites

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 :)

Edited by duke_meister
added stuff; removed quote

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites
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?

Edited by duke_meister

Share this post


Link to post
Share on other sites

************** Exception Text **************
System.ArgumentException: Parameter is not valid.
   at System.Drawing.Bitmap..ctor(String filename, Boolean useIcm)
   at WindowsFormsApp1.Form1.Form1_Paint(Object sender, PaintEventArgs e) in C:\Users\Owner\documents\visual studio 2017\Projects\WindowsFormsApp1\WindowsFormsApp1\Form1.cs:line 32
   at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Form.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!