I currently have a school project and I'm making a game. Here's my code:
public partial class room2 : Form
{
public room2()
{
InitializeComponent();
Random rand1 = new Random();
Int32 t =6 ;
Int32 Fight = rand1.Next(1, 11);
Int32 J = 10;
label4.Text = Convert.ToString(10);
if (Fight <= t)
{
label3.Text = Convert.ToString(J);
}
else
{
txtDialogBox.Text = ("No Fight in this room");
}
}
private void Attack_Click(object sender, EventArgs e)
{
Random rand2 = new Random();
Int32 J = 10;
Int32 Attack = rand2.Next(1, 4);
Int64 y = 1;
Int64 t = 10;
//opponents hp bar goes down by 1
J --;
label3.Text = Convert.ToString(J);
// chance for your hp bar to go down
if (Attack >= y)
{
label4.Text = Convert.ToString(t);
t--;
}
}
}
When I put the Ints at the top (like I was told to ) I get errors ("does not exist in current context") and I found that the only way for me to fix it is to put it in with the button.
Int32andInt64? Looks like you should just be usingintInt32has a size of4 bytes, whileInt64has a size of8 bytes. Now,intis just an alias for sayingInt32, so you got that right aboutintandInt32being equal.