none
How to make more instances of an image to appear on window ? RRS feed

  • Question

  • How can i have more instances of the same image on the graphics window ? And also what function does make a new instance ? 
    I really need this, biggest code i need...

     

    Thanks in advance <.< =). 


    I love game design and game programing.
    Sunday, September 4, 2011 8:45 PM

Answers

  • You can store an image once in ImageList and then create an array of sprites using the same image.

    myImagURL = Flickr.GetPictureOfMoment()
    myImage = ImageList.LoadImage(myImagURL)
    widthImage = ImageList.GetWidthOfImage(myImage)
    heightImage = ImageList.GetHeightOfImage(myImage)

    For i = 1 To 100
      image[i] = Shapes.AddImage(myImage)
      Shapes.Zoom(image[i],0.2,0.2)
      Shapes.Move(image[i],Math.GetRandomNumber(GraphicsWindow.Width)-widthImage/2,Math.GetRandomNumber(GraphicsWindow.Height)-heightImage/2)
    EndFor

    • Marked as answer by Primoz128 Monday, September 5, 2011 3:42 AM
    Sunday, September 4, 2011 10:42 PM
    Moderator

All replies

  • You can use the imagelist so you can have faster image loading, because you don't have to reload it every time you draw it. Use this:

    myimage = Imagelist.LoadImage("MyFilePath.png")

    i1 = Shapes.AddImage(myimage)

    i2 = Shapes.AddImage(myimage)

    Shapes.Move(i2, ImageList.GetWidthOfImage(myimage), 0)



    ~~AirWaves!!~~
    Sunday, September 4, 2011 9:04 PM
  • Ok... what about if i go making a maze game, do i need like 40 variables for instances or what... im not sure if that is fast.
    I love game design and game programing.
    Sunday, September 4, 2011 10:32 PM
  • You can store an image once in ImageList and then create an array of sprites using the same image.

    myImagURL = Flickr.GetPictureOfMoment()
    myImage = ImageList.LoadImage(myImagURL)
    widthImage = ImageList.GetWidthOfImage(myImage)
    heightImage = ImageList.GetHeightOfImage(myImage)

    For i = 1 To 100
      image[i] = Shapes.AddImage(myImage)
      Shapes.Zoom(image[i],0.2,0.2)
      Shapes.Move(image[i],Math.GetRandomNumber(GraphicsWindow.Width)-widthImage/2,Math.GetRandomNumber(GraphicsWindow.Height)-heightImage/2)
    EndFor

    • Marked as answer by Primoz128 Monday, September 5, 2011 3:42 AM
    Sunday, September 4, 2011 10:42 PM
    Moderator
  • I think i found a solution in my head just now... i will be making a level editor myself.

    I will use a variable, but i can't use it in betwen... ill have to research a bit o.O.


    I love game design and game programing.
    Monday, September 5, 2011 3:41 AM
  • Just to help you with your maze for collision detection:

    BDZ554


    ~~AirWaves!!~~
    Monday, September 5, 2011 5:27 AM
  • Wow thanks man... i almost allways stop at problems i know i will need lots of time or not that much at all to put in... well i have re designed my whole computer ergodinamic - hope that is correct word... and i also bought a great keyboard i hope it is that arrives tomorov, need to have good stuff not bad. 

    I will use 2 dimensional array for same properties Game Maker uses and almost in same way.


    I love game design and game programing.
    Monday, September 5, 2011 2:16 PM