Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Error: Cannot allocate item. Out of id numbers (max 1000)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kactus




PostPosted: Sat Apr 15, 2006 12:31 am   Post subject: Error: Cannot allocate item. Out of id numbers (max 1000)

So ive turned the moving dot tutorial into a simple program with a picture instead of a dot a BG and while I am playing it i get this Error: Cannot allocate item. Out of id numbers (max 1000) can anyone help?

here is the code:

code:
View.Set ("offscreenonly")
colorback (white)

var bg : int := Pic.FileNew ("BG.bmp")
var obj1 : int := Pic.FileNew ("bush.bmp")
var sprite : int := Pic.FileNew ("Marioright.bmp")
var x, y : int
var chars : array char of boolean

x := 10
y := 46

loop
    Pic.Draw (bg, 0, 0, 0)
    Input.KeyDown (chars)

   % if chars (KEY_UP_ARROW) and y < maxy - 30 then
    %   y := y + 1
   % end if
    if chars (KEY_RIGHT_ARROW) and x < maxx - 10 then
        x := x + 1
        sprite := Pic.FileNew ("Marioright.bmp")
    end if
    if chars (KEY_LEFT_ARROW) and x > 10 then
        x := x - 1
        sprite := Pic.FileNew ("Marioleft.bmp")
    end if
    if chars (KEY_DOWN_ARROW) and y > 46 then
        y := y - 1
    end if

    Pic.Draw (sprite, x, y, picMerge)
    Pic.Draw (obj1, 80, 46, picMerge)
    delay (10)
    View.Update
    cls

end loop
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Sat Apr 15, 2006 2:49 am   Post subject: (No subject)

That's because you're allocating a new picture at each iteration of your loop with Pic.FileNew(). What you should be doing is loading all your neccessary pictures at the start of the program (as you have done with Marioright.bmp) and then just changing which picture is being drawn inside the loop. What I suggest you do is have a variable which holds the last directional key pressed, and draw the picture based on that variable.
Kactus




PostPosted: Sat Apr 15, 2006 1:24 pm   Post subject: (No subject)

it worked! thank you
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: