picking image object to put on a scenerio

BlitzMax Forums/BlitzMax Beginners Area/picking image object to put on a scenerio

kiami(Posted 2005) [#1]
I am very new to game programming. I am trying to imagine programmatically how to click on a list of objects/images and paste one on a game scenario at run-time.

I am not worry about picking or dragging or pasting. Here is what I have no clue: we know graphic drawing must be coded in game loop. But game loop only draws the number of object/images that are equal to DrawImage function. In what I am doing, I need to have actually a new object with image being added to existing one and programmatically being controllable while loop is going. I thought I have to code a maximum number of objects in the game loop with being disabled conditionally. Then, when I want to have a new one appear, I simply enable one by making it conditionally true. As an example: suppose there are two ducks on a lake. Then you want to add 5 boats. It seems to me that I have to make boat objects pre-programmed and simply make them available conditionally. Is it possible to have a dynamic object creation on run time? I think not, and seem to be a stupid question, but I ask anyway.


Am I confused? Is this the way that it must be done?


Bot Builder(Posted 2005) [#2]
You've confused me i think.... Drawimage draws an image onto the screen, ok? You can draw an image you've loaded as many times as you like. In most 2d programs he drawimage command just copies the image pixels onto the 'backbuffer' (virtual screen to reduce flicker). Then 'flip' is called which moves that data to the screen. Finally, you clear the back buffer to black using 'cls' if you aren't drawing over everything. (if you are its faster to leave it out).

You can have dynamic object creation. you can in any language i've ever learned.... You don't need it in this case though because you can just load up one instance of each image file and draw it wherever you like.

[edit]Ohh, ah, you want to allow the user to add images then? I would do this:

Type GameObject ;whatever name is fine
 Field Image
 Field x,y, Frame
End Type

Graphics 640,480
SetBuffer BackBuffer()

While not Keyhit(1)
 For go.GameObject=Each GameObject
  DrawImage Image,x,y,frame       ;not sure about parameter order - its been a while
 Next
 Flip
 Cls
Wend


Obviously I've left out creation of any images.


kiami(Posted 2005) [#3]
I am sure I have confused you because I feel to be confused and not sure I am putting my question right. But let me try.

The number of objects that your for-loop creates is predetermined. For example, suppose we want DrawImage draws 15 objects initially. Now, my question is how do I add 11 more on run-time? Should I draw 15+11=26 objects initially and make 11 of them disabled to be enabled later on run-time? Or there is something missing in my thought.


Duckstab[o](Posted 2005) [#4]


Just a few of the basics For adding objects to lists this would be one way as none are created in a preditermined way.
In this programme its using input from keypresses Z,X,Space to add random amound of oval or Rectangles To a Tlist.

You can Remove the Rnd(5) in the Getinput() function and Set it to any value


kiami(Posted 2005) [#5]
Yes, thanks, just in every iteration one can add an object/image to a list. Sometimes my brain becomes lazy!