Type lists help needed...
Monkey Forums/Monkey Programming/Type lists help needed...
| ||
Hi Everyone! I've been trying to figure this out but for some reason I just can't seem to find any documentation on how its done so I'm hoping some awesome chap/chapette that can help me out :) What I want to do is create an undefinable amount of objects (particles for this example) that I can then draw to the screen. So what I'm trying to do is to create a new class when I want to and then just go through the list of these particles at draw time. In Blitz you just create a new type and then run through the list of those created types with a simple 'for' loop. How would I do something similar in Monkey? I've added my code for this so far. As you can see I've set up the class and that's about it :) All the best! Mike 'CODE STARTS HERE ' Import mojo Import mojo.app Import mojo.graphics Class MyApp Extends App Method OnCreate:Int() SetUpdateRate 60 End Method OnUpdate() End Method OnRender() End End Function Main() New MyApp End ' PLAYER CLASS ' Class Particle Field posX:Int Field posY:Int Method Draw:Void(positionX:Int, positionY:Int) posX=positionX posY=positionY DrawPoint (PosX,posY) End End |
| ||
You should view InvaderJim's tutorials. The method below uses a static variable (Global) to hold a list of particles and some static functions to create, update and draw all the particles. But there is nothing to stop you from creating a member variable (Field) in a class as a particle list and using Methods in stead of functions to create particles. |
| ||
Hi! This is fantastic!! :D Thank you so much for such super feedback! :D all the best! Mike |