Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Purge1t

@Purge1t
About
Posts
6
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Lists of objects without losing class Intelli-sense
    P Purge1t

    Thanks Dave.

    Quote:

    The same is true for the Draw method. Every object should draw itself, so you pass in a Graphics object that it uses to draw itself on. This is common for every object you mentioned, so it should go in the Base object they are inheriting from, not the specific objects.

    The PlayerShip class draws a circle, the Missile class draws a triangle and the EnemyDrone class draws a square. How would i know how to depict each different class type if the drawing was done in the base class? Instead of having a MustOverRide .Draw method in the base class that each of the child-classes over-ride ?

    Visual Basic tutorial question learning workspace

  • Lists of objects without losing class Intelli-sense
    P Purge1t

    Thanks for the naming scheme advice. What I use for my project is a lot easier. It was just a quick example. I should have made it easier to read, sorry. My primary issue is that I need to have multiple class objects that behave differently (playership, enemy drone, missile etc) held in a single container so that my main loop can enumerate through them all. For example.

    For i as integer = 0 to blobs.count - 1
    blobs(i).AiTick
    blobs(i).Move
    blobs(i).Draw
    Next i

    The only way I could find to do this was to create a base class with the ai/move/draw methods in it and have different classes inherit from the base class and over-ride the base class's methods. The main issue i have is that these classes that inherit from the base class occasionally have extra methods. I would like to see those when i'm coding things like blobs(0).ExtraMethod like i can for the base class. I guess what i'm asking isn't possible. If ClassA inherits BaseClass and ClassB inherits BaseClass but ClassA also has an extra method called "ExtraMethod" then I already run the risk of accidently executing ExtraMethod on the item in the collection that is ClassB and causing an exception. I deal with that issue already in my code, so i don't understand why the dev environment is perfectly fine with me making a list(of Objects) and running List(0).ExtraMethod ... however when I ask it to have a list of BaseClass it doesnt goto the effort of listing what's availiable in any classes that inherit from BaseClass. I guess I will just continue to have a list(of Object) instead of a list(of BaseClass) and continue running extra methods from classes that inherit from BaseClass as I currently do by first checking the object type.

    Visual Basic tutorial question learning workspace

  • Lists of objects without losing class Intelli-sense
    P Purge1t

    Hi Guys, Is it possible to have a list/collection of objects that inherit from a single base object without losing Intelli-sense? Here is an example of what I mean...

    Public Class baseblob

    Private \_position As PointF
    
    Property position
        Get
            Return \_position
        End Get
        Set(value)
            \_position = value
        End Set
    End Property
    
    Sub New()
        position = PointF.Empty
    End Sub
    

    End Class

    Public Class blob

    Inherits baseblob
    
    Sub moveRight(ByVal Distance As Single)
    
        position = New PointF(position.X + Distance, position.y)
    
    End Sub
    

    End Class

    Public Class Form1

    Dim blob As New blob
    Dim blobs As New List(Of baseblob)
    
    Private Sub Button1\_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    
        blob.moveRight(10)
        MsgBox(blob.position.x)
    
        blobs.Add(blob)
        MsgBox(blobs(0).position.x)
    
        blobs(0).moveright(10)
        MsgBox(blobs(0).position.x)
    
    End Sub
    

    End Class

    ... but of course in the above example i get

    'moveright' is not a member of 'oopTest.baseblob'

    :doh: So it wants me to use

    Dim blobs As New List(Of Object)

    So it will compile and work as intended... I just wanted to know is there something I'm missing here? Why can't I just let it know that it's a base object and to list all the possible methods/properties etc of the base class and also any objects that inherit the base class? Give me the lot! To me it doesn't sound like such a hard thing to ask of the compiler/dev environment... why cant it do it ? :(

    Visual Basic tutorial question learning workspace

  • Hyper V
    P Purge1t

    You obviously aren't trying to use it with Linux or the first sentence would be very different.

    The Lounge sysadmin windows-admin announcement

  • 'Self-aware' classes?
    P Purge1t

    Thank you so very much for taking the time to reply. The largest problem I have at the moment is actually my physics routine increasing in ms/tick at a dramatic rate. This physics routine calculate the gravity between EACH space entity. As a dense rock or even a ejection pod has density (as well as the blackholes [warpholes] and planets etc). I have optimised this routine many many times to keep reducing the time it takes but it's near 'perfect' for my level of knowledge. I would love to have more then 100,000 objects in my 'universe' however any more then that and I start to suffer noticeable lag. I wonder if the quadtree method will assist with this problem. I'll look into it! Thank you

    Game Development help question csharp game-dev

  • 'Self-aware' classes?
    P Purge1t

    Hi guys... long time reader first time poster. Please be gentle. I avidly create games in VB.net. Being a hobby programmer I give my games away for free. Since I'm a hobbiest without formal training I do try and educate myself on proper programming principles and follow them when programming such as OOP. There are however some things I have obviously missed being self-taught that perhaps I would know if I were formally educated. Once such issue that has really been my bane is how different classes (from now on referred to as objects) 'know' about each other WITHOUT programming specific interaction (stay with me here... please...) Okay imagine this, you have a space game and the following objects clsShip clsMissile clsAsteroid clsSpaceJunk Now each one of these objects has a Health, X,Y and Z private members and properties that are all inherited from clsSpaceEntity for argument sake. Now one way of programming collision between them would be to code out the following logic in the main game loop for each ship in a list of ships check each clsMissile in a list to see if it collides with it and if so, reduce health check each clsAsteroidin a list to see if it collides with it and if so, reduce health check each clsSpaceJunka list to see if it collides with it and if so, reduce health ... and so on and so on for every object next ect ect ect... Now this might seam okay if your talking about the simple example above but some of my games have tens or even HUNDREDS of objects that interact in this basic way. Now my question to the experienced programmers out there. Is there a way in OOP to do the following... for each thing that inherits from clsSpaceEntity check against every other object that inherits this type (except itself) and if they collide then reduce health next ? This sort of ability for a type of objects/class or whatever to be 'aware' of another and how they are the same/different and interact would save me tonnes and tonnes and TONNES of coding. Any assistance/help or feedback on this would be very appreciated. Thank you for your time, sorry for the long read.

    Game Development help question csharp game-dev
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups