views:

19

answers:

1

the code i have that interacts with e.graphics is

'clear area
e.Graphics.FillRectangle(Brushes.Black, 0, 0, 600, 800)
'draw sand
For Each i In world
    e.Graphics.FillRectangle(i.getcolor, i.getx, i.gety, 1, 1)
Next

here are the variable areas of my two classes, along with their new functions; assume that the get lines do what you think they do.

Public Class Sand
    Private x As Integer
    Private y As Integer
    Private type As element
Public Sub New(ByVal x As Integer, ByVal y As Integer, ByVal type As element)
    Me.x = x
    Me.y = y
    Me.type = type
End Sub

Public Class element
    Public color As Color
    Public weight As Integer = 1
    Public spread As Double = 0.5
    Public text As String = "null"
    Public Sub New(ByVal c As Color, ByVal w As Integer, ByVal s As Double, ByVal t As String)
        color = c
        weight = w
        spread = s
        text = t
    End Sub

here is the spot in my program that dimensions the world variable and such.

Private world As List(Of Sand)
Private paused As Boolean = False
Private openbottom As Boolean = False
Private selected As Integer = 0
Private elements As List(Of element)
'DEBUG VARIABLES
Private debugmode As Boolean = True
Private framenum As Integer = 0

and here is the area in my debug portion that makes a 4 grains of sand in 2 different elements.

elements.Add(New element(Color.Azure, 1, 1, "Test El 1"))
elements.Add(New element(Color.Aqua, 1, 1, "Test El 2"))
world.Add(New Sand(240, 400, elements(1)))
world.Add(New Sand(440, 200, elements(1)))
world.Add(New Sand(340, 100, elements(2)))
world.Add(New Sand(540, 400, elements(1)))
A: 

A red x's over the main window means that your custom drawing code launches an exception. Is world null? Is some i null?

Victor Marzo
I will check to see if something might be.
crazybmanp
i have posted some more of the code, i think the problem might be in the way i am using the lists.
crazybmanp
i have added a part to make it start without running the timer, and to not complete the pain function without the user telling it to start. and the red X does not appear until the pain command is called. although when trying to debug, i put these two lines at the end of the loadup debug and they do nothing. MessageBox.Show(world(1).getx.ToString)MessageBox.Show(world(2).getelement())no messagebox ever shows up.
crazybmanp