Reputation: 0 Apprentice
- New Members
- Active Posts:
- 9 (0.01 per day)
- 11-December 12
- Profile Views:
- Last Active:
- Dec 13 2012 11:15 AM
- Dream Kudos:
Posts I've Made
Posted 12 Dec 2012
Posted 12 Dec 2012I DID IT!
ALL I DID WAS ADD
TO MY SPAWN LOOP! THANK YOU SO MUCH TREVSTER!
I LOVE YOU! (As much as a stranger can love another stranger)
Posted 12 Dec 2012Okay well you can use a for each loop which will run through each element in an array, or list, or whatever allowing you to search for conditions or whatever you want.
For each Sprite as Picturebox in PictureboxList 'code here Next
There are more advanced ways to do this, but I won't list them lol.
I'VE DONE IT... kind of.
They're spawning and the attributes are there... except they apparently don't like to spawn with their sprites showing. In other words... THEY'RE INVISIBLE! What do I do? I mean, they SHOULD be spawning with a picture...
For Me.i = 0 To 1 Dim NewBat As New PictureBox Dim NewSlime As New PictureBox NewBat.Size = New Size(50, 50) NewSlime.Size = New Size(50, 25) NewBat.Location = New Point(367, 211) NewSlime.Location = New Point(367, 211) NewBat.BackgroundImage = My.Resources.Bat NewSlime.BackgroundImage = My.Resources.slime Batbox.Add(NewBat) Slimebox.Add(NewSlime) Next i
Posted 12 Dec 2012I'd say just create a List(Of Picturebox) and store them in that.
Yes that would make it accessible.
On a side note I'd definitely suggest not relying on picturebox's so heavily. Should my tutorial be approved soon I'll give you a link to it. It goes over Drawing, and the Picturebox, both pros and cons, and the basics of each when it comes to game creation as well as usage.
Also did you try using a breakpoint to double check all your values are correct?
I'm not entirely sure on Lists. Do I have to have all the picture boxes already there? and if I do, could I just have four or five picture boxes and it cycles through them?
Another question, if I can't use picture boxes, what else could I use to make my monsters?
I'm still fairly new to VB.net, only started it in september />/>/>/>/>/>
and yeah, I put a break-point and everything looks fine and dandy.
did you try putting a stopper on the for loop and f10 the thing until you get the error?
I get the error on the if... statement.
Dim ListBox as new List(Of Picturebox) For i = 0 to 1 Dim Newpic as new Picturebox Listbox.add(NewPic) Next
You can use a for each loop to run through all the items in the list as well.
You can use drawing. Which uses the System.drawing.graphics object to grab the handle to a child window, or parent window for drawing.
Dim G as System.Drawing.Graphics = System.Drawing.Graphics.FromHwnd(Me.Handle) 'form1.handle Dim MyImage as Image = Image.FromFile("C:\testpic.jpg") G.DrawImage(MyImage, NewPoint(50, 50)) 'Draws the image at the specified point in the handle given to it. G.dispose
Well, I've switched to using lists, but not I need to figure out how to set up my other attributes for the newly created pictures. For example, my attack collision. How will I check if my attack is hitting the newly formed picture box?
QuoteIf you're not completely familiar with objects, or the fundamentals of Object Oriented Programming then I'd say pause your project here, and go learn that. Practice it, gain a solid understanding of it.
Best source here: OOP Fundamentals - MSDN
I really wish I could
Unfortunately, I have roughly Seven days to finish this, as this is my final project for my Computer Science class... as I've said before, I'm notorious for biting off more than I can chew
Posted 12 Dec 2012300 lines of code for one single class? This is so called spaghetti code. I just skimmed through your code, and have seen some confusing things: variable i, strange usage of for loops (I can't really explain to myself what should be the point of For Me.i = 1 To 1 and For x = 1 To 1...). In my opinion, you should refactor your code, separate concerns, and do some debugging.
If you get error message, telling you that you need to instantiate object first, before you use it, then do it. You can't add non existing picturebox to controls (you can't add nothing).
Like I've said, I'm fairly new to VB.net (heck, coding in general) and my teacher hasn't taught me any of the things you're talking about. And I had my arrays linked to a picture once and it went a little like this:
Bats(i) = picEnemy1 Slime(i) = picEnemy2
and all it would do is just move the picture... which isn't what I wanted
I just want to finish this project...
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
AshinoxVGs hasn't added any friends yet.