943,539 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1615
  • C# RSS
Oct 12th, 2008
0

How do you draw a bar

Expand Post »
Im new to C# and im trying to create a simple RPG game. Im trying to show stats like health and exp but I dont know how to draw a line to show them.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Chris11246 is offline Offline
28 posts
since Jan 2008
Oct 13th, 2008
0

Re: How do you draw a bar

Try FillRectangle from Graphics class
Reputation Points: 11
Solved Threads: 9
Junior Poster in Training
vckicks is offline Offline
58 posts
since Jun 2008
Oct 13th, 2008
0

Re: How do you draw a bar

here i have written some code for you using GDI that can give you the clue for your problem:

C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9.  
  10. namespace GDI1
  11. {
  12. public partial class Form1 : Form
  13. {
  14. Pen BluePen = new Pen(Color.Blue, 1);
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. Graphics dc = this.CreateGraphics();
  19. this.Show();
  20.  
  21. dc.DrawRectangle(BluePen, 0, 0, 50, 50);
  22. Pen RedPen = new Pen(Color.Red, 3);
  23. Pen pen2 = new Pen(Color.LightSalmon, 10);
  24.  
  25. Pen test = new Pen(Brushes.YellowGreen,8);
  26. dc.DrawEllipse(test, 50, 50, 200, 200);
  27. Point[] p = new Point[] { new Point(1, 2), new Point(70, 120), new Point(100, 200), new Point(280, 290), new Point(1, 2) };
  28. Point[] p2 = new Point[] { new Point(10, 10), new Point(310, 10), new Point(310, 310), new Point(10, 310), new Point(10, 10) };
  29.  
  30. dc.FillEllipse(Brushes.YellowGreen, 50, 50, 200, 200);
  31.  
  32. Brush b1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, Color.Red);
  33. dc.FillEllipse(b1, 50, 50, 100, 100);
  34. dc.DrawLine(BluePen, 0, 0, 600, 600);
  35. dc.DrawLine(BluePen, 600, 0, 0, 600);
  36. dc.DrawLine(RedPen, 0, 300, 600, 300);
  37. dc.DrawLine(RedPen, 300, 0, 300, 600);
  38. dc.DrawLines(pen2, p2);
  39. }
  40.  
  41. }
  42. }

Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]
Reputation Points: 10
Solved Threads: 0
Newbie Poster
toraj58 is offline Offline
7 posts
since Sep 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC