Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Go Back  Xtreme Visual Basic Talk > > > Random Monster Generating + Array of Objects


Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2011, 12:07 AM
Exiled Exiled is offline
Newcomer
 
Join Date: Jun 2011
Posts: 10
Default Random Monster Generating + Array of Objects


I'm making a top-down dungeon crawler. I've been working on random monster generating. The drawing part works perfectly. It generates 8 random monsters, at random locations around the map. Collision works fine, everything. But of course, I needed to add stats to each monster. So to do this, I've created a Monster class with 5 members(defense, level, health, x, and y). Then, I created a 1D array of objects of Monster. When the monster is randomly generated, I've made it so it also sets a new object's stats using random numbers. However, when I added this code, only ONE monster appears onthe map, when there should be 8. I'm completely stumped on what to do, for I'm not sure what's causing it. I didn't describe every aspect of my code, so I'll paste.

Code:
   
Private Sub EnemySpawning()

        monstercount = 0

        While monstercount < 8
                M1 = RandomClass.Next(17, 100) ' Random number generating. The number will be generated between 17 and 100.
                M2 = RandomClass.Next(17, 100)
                M3 = RandomClass.Next(0, 5)
                HR = RandomClass.Next(10, 30)
                DR = RandomClass.Next(3, 10)
                LR = RandomClass.Next(1, 3)
                If Map(M1, M2, 0) = 0 Then ' If the randomly selected tile is cobblestone, the ground tile.
                    NPC(M1, M2, 0) = M3 ' Setting the coordinate to a certain source rectangle to draw a monster.
                Map(M1, M2, 0) = 4 ' Setting the coordinate to an un-passable cobblestone.
                monstercount = monstercount + 1 ' Adding 1 to the number of monsters integer.
            End If
        End While
    End Sub
If you need any more information, please let me know.
Reply With Quote
  #2  
Old 06-21-2011, 02:28 AM
PlausiblyDamp's Avatar
PlausiblyDampRandom Monster Generating + Array of Objects PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

From the code you posted I can't seem to see where you are creating an instance of the monster class or where you are adding an instance of the class to the map.

Could you give a little more detail as to what the various variables used in the posted code are.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 06-21-2011, 02:39 AM
Exiled Exiled is offline
Newcomer
 
Join Date: Jun 2011
Posts: 10
Default

Argh... Actually, I figured it out. The problem was I wasn't creating the elements of the array, I was simply defining the array.

This was the code I forgot.
Code:
For X As Integer = 0 To 10
    MeV(X) = New Monster()
Next X
I feel stupid, heh. Sorry for your time, but thanks. :|
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
 
Random Monster Generating + Array of Objects
Random Monster Generating + Array of Objects
 
-->