• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By Just4lol
      I'm looking for my dream teammate(s) to help me work on my Unity game. I still dont know where Im going with that project but I want to make a good final product that I would be able to sell or publish it for free on Steam.  Here a video of the prototype (The only thing I dint made is the skybox) https://www.youtube.com/watch?v=y2Otmt9jRkc
      My discord : Just4lol#46982
      I want somone at least as competent as me : 
      - I want somone with at least one year of experience in Unity (already worked with scriptable object and know oop).
      - Already worked with shaders or can do editors tools is a plus.
      - Can do 3d models in Blender or can do 2d art for the ui or particles effects.
      - Can make soundtracks or sound effects a bonus.
      Im a french Canadian so mind my english I will do my best to edit any errors I see. 
    • By Damnwing0405
      I am looking for talents to form a team of making a strategy base action game. Talents I am currently looking for are : -
      (I) Unity programmer (mobile)
      (II) Game designer
      (III) 3d Artist
      (IV) SFX Artist
      The attachment is some game concept for the game. All the concept will be turn into 3d or card form. The game will be strategy game where the players can form their own team and control the units in the battle field real time to fight against each others.  If you are interested to know more details please pm me or send an email to damnwing0405@gmail.com

    • By bsudheer
      Leap Leap Leap! is a fast-paced, endless running game where you leap from rooftop to rooftop in a computer simulated world.

      This is a free run game and get excited by this fabulous computer simulated world of skyscrapers and surreal colors in parallax effect. On your way, collect cubes and revival points as many as you can to make a long run.

      Features of Leap Leap Leap:
      -Option of two themes: Black or White.
      -Simple one touch gameplay.
      -Attractive art.
      -Effective use of parallax.
      To Download the game:
      Playstore: https://play.google.com/store/apps/details?id=com.avakaigames.leap
      Appstore: https://itunes.apple.com/us/app/leap-leap-leap/id683764406?mt=8

    • By BillyGD

      Play Flick Football 3D @ https://gamejolt.com/games/flickfootball3d/326078
      Check out our Facebook page @ https://www.facebook.com/FlickFootball3D/
      Flick Football 3D is a turn based football game inspired by the table top classic 'Subbuteo'.
      The game is currently in very early Alpha development. There is still a lot to be done before the first proper release but I have decided to release this playable version to get as much feedback as possible.
      The only game mode currently available in this release is the 'Practice Mode' which gives you control of both teams. Either play against yourself to get used to how the game works or play against friends and family on the same computer!
      Planned Future Features Include:
      -Take control of your own custom team in the single player campaign.
      -Play in online leagues and tournaments against other players in the multiplayer mode.
      -Fully customisable stadiums to make you stand out from the rest of the players.
      -Improve your players stats and skills by playing matches and setting up training sessions.
      Flick Football 3D is available for Windows, Mac and Browser.
      Thank you for viewing my game, all feedback is greatly appreciated. I can be contacted at; BillyGDev@outlook.com
      'Flick Football 3D' is also the development name for the game and I haven't yet decided what the full release will be called, so if you have any ideas please drop me a message!
    • By drcrack
      It is a combination of fundamental RPG elements and challenging, session-based MOBA elements. Having features such as creating your unique build, customizing your outfit and preparing synergic team compositions with friends, players can brave dangerous adventures or merciless arena fights against deadly creatures and skilled players alike.

      This time with no grinding and no pay to win features.

      We're still looking for:
      1) 3D Character Artist
      2) 3D Environment Artist
      3) Animator
      4) Sound Designer
      5) VFX Artist

      Discord https://discord.gg/zXpY29V or drcrack#4575
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity [.net] Graphics Problem in C#

This topic is 3966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to use some code I found on a different topic: http://www.gamedev.net/community/forums/topic.asp?topic_id=429322 to create a map editing program for my online RPG. I've gotten most of it figured out except for the DrawImage command. This is the code I have at the moment. **MYSQL Information** baseloc = OdbcDR[4].ToString(); Bitmap bmp = new Bitmap(System.Convert.ToInt32(OdbcDR[6])*27, System.Convert.ToInt32(OdbcDR[7])*27); mappicbox.Image = bmp; // do every time you redraw Graphics gfx; for (int x=0;x<=System.Convert.ToInt32(OdbcDR[6]); x++) { for (int y=0;y<=System.Convert.ToInt32(OdbcDR[7]);y++){ **Mysql Information** topx = x*27; topy = y*27; Image tile = Image.FromFile(@"C:\\xampplite\\htdocs\\Arakaron\\game\\Images\\map\\"+baseloc+"\\"+OdbcDR[2].ToString()+".bmp"); gfx.DrawImage(tile, topx, topy, 27, 27); } } Basically it is telling me that the variable gfx is a local unassigned variable. And when i use Graphics.DrawImage it tells me that an object reference is required for the non-static field, method, or property 'System.Drawing.Graphics.DrawImage', and if i try to use e.Graphics i get System.EventArgs does not contain a definition for 'Graphics'. Any help would be greatly appreciated.

Share this post

Link to post
Share on other sites
Well what do you want to draw to? If it's a control(like a form or panel) then assign gfx using Drawing.Graphics.FromHwnd, if it's a Drawing.Bitmap use Drawing.Graphics.FromImage

Share this post

Link to post
Share on other sites
Well i figured the easiest way to do this, and what i understood from the other topic is, to create a graphic composed of the individual tiles for each (x,y) location. Then convert this to a bitmap and use set it to the image of a picturebox. I'm not sure if this is the easiest and most accurate way to do it, but thats how I am attempting to proceed.

Share this post

Link to post
Share on other sites
A much better way would be to overload the form's OnPaint method and do your painting there using the passed in Graphics object.

Also, some things you may want to set on the form:
DoubleBuffer = true;
ResizeRedraw = true;
Setstyle(Controlstyles.AllPaintingInWmPaint | Controlstyle.UserPaint, true);

If you need more help feel free to ask.

Share this post

Link to post
Share on other sites
I'm not too sure what to do, because I can't even create the gfx graphics. I've tried everything I can, but it keeps giving me the error I presented in my first post.

Share this post

Link to post
Share on other sites
Your problem is that Graphics gfx; just produces a null reference. It hasn't been assigned to refer to any actual Graphics instance yet. Try this with an additional bitmap:
Graphics gfx = System.Drawing.Graphics.FromImage(bmp);
This will make a graphics object that uses the specified bitmap as its underlying image source. Then, all .DrawImage() calls you make to it will be drawn to the bitmap. Later, you can do whatever you want with this bitmap, including drawing it to other Graphics objects, such as the one given to you in the OnPaint method.

Or you could do what others have suggested and use an already existing Graphics object. Depending on what mappicbox is, it may contain a .Graphics property. Then you can just do:
Graphics gfx = mappicbox.Graphics;

Share this post

Link to post
Share on other sites
Well I've got it working, except for two small problems. My maps are looking all screwy, and I need to figure out a how that I can check to see if a tile is located in the file path. If it isn't then replace it with a blank image. Also, I would like to try to find a way that I can check to see if the database has a value in it. To make the tables smaller I removed some of the base repetetive tiles such as grass, dirt, etc. Each map has its own base tile (dungeon has dirt, etc). So if there isn't a value in the table for say (3,3) then I want to make the tile the default tile. Anyone know of a way to check for this? I can do it in php, but unsure how to do it in C#.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement