Results 1 to 10 of 31

Thread: Dynamic in-game object creation and manipulation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Firstly dynamic arrays start at 0 so you should do :

    Code:
    for I := 0 to numofbullets-1 do
    Secondly your answer my lie in your checks - you've got an array of bullets and you're checking to see if a member is nil before you render - perhaps they are nil? please post your code for how you setup the array of bullets so we can check to see if that's a factor.

    Thirdly you have a 'picture' property for each bullet - if each bullet has a different image then this is fine but I'm guessing you only have a single bullet texture - it's best to load it once and draw it over and over for each bullet - only storing the unique properties per bullet IE :

    Code:
    Canvas.Draw(bullets[i].xplace,bullets[i].yplace, FGlobalBulletPicture);
    and lastly because dynamic arrays start at 0 you don't need :

    Code:
    if numofbullets>1 then
    (but that should read numofbullets > 0 or numofbullets >= 1) because :

    Code:
    for I := 0 to numofbullets-1 do
    when numofbullets = 0 equates to :

    Code:
    for 0 to -1 do
    Which will not enter the loop (use 'downto' instead of 'to' if you want to use descending for loops)
    Last edited by phibermon; 19-12-2015 at 06:52 PM.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •