Member Avatar for Chris11246

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.

Try FillRectangle from Graphics class

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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace GDI1
{
    public partial class Form1 : Form
    {
        Pen BluePen = new Pen(Color.Blue, 1);
        public Form1()
        {
            InitializeComponent();
            Graphics dc = this.CreateGraphics();
            this.Show();
 
            dc.DrawRectangle(BluePen, 0, 0, 50, 50);
            Pen RedPen = new Pen(Color.Red, 3);
            Pen pen2 = new Pen(Color.LightSalmon, 10);
            
            Pen test = new Pen(Brushes.YellowGreen,8);
            dc.DrawEllipse(test, 50, 50, 200, 200);
            Point[] p = new Point[] { new Point(1, 2), new Point(70, 120), new Point(100, 200), new Point(280, 290), new Point(1, 2) };
            Point[] p2 = new Point[] { new Point(10, 10), new Point(310, 10), new Point(310, 310), new Point(10, 310), new Point(10, 10) };

            dc.FillEllipse(Brushes.YellowGreen, 50, 50, 200, 200);

            Brush b1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, Color.Red);
            dc.FillEllipse(b1, 50, 50, 100, 100);
            dc.DrawLine(BluePen, 0, 0, 600, 600);
            dc.DrawLine(BluePen, 600, 0, 0, 600);
            dc.DrawLine(RedPen, 0, 300, 600, 300);
            dc.DrawLine(RedPen, 300, 0, 300, 600);
            dc.DrawLines(pen2, p2);
        }

    }
}

Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.