I don't think I've ever got an object to drop at a sprite position, I've only ever managed to drop it on a screen where the position was determined when you are editing and pressed p for position in OBJECTS
If we use PUT outside the Sprite #0 routine, AGD crashes (tested), because it needs player's X Y coordinates. So PUT command drops collected objects in player's position (like in Atic Atac, sometimes it could be useful to bring objects and drop them elsewhere)...
In order to avoid objects to reappear onto our rooms, maybe manually we have to do something like this :
IF KEY 4 IF GOT 2 (assuming 2 is the object) LET OBJ = 254
That won't work, because OBJ is only the result of DETECTOBJ, i'm not sure if we can assign other values to it...
Post by Jonathan Cauldwell on Dec 21, 2013 13:54:30 GMT
The object handling isn't designed that way. Objects can only be picked up and dropped by sprites. If no sprite is defined (eg you're dropping an object from somewhere other than in a sprite event) AGD will attempt to place the object at whatever sprite coordinates it finds, which will be complete nonsense. When it attempts to draw that object it could be off-screen, which means system variables, BASIC, streams etc could be overwritten... hence the crashes. It doesn't have to be the player sprite though. Any sprite should be able to pick up and drop an object.
I'll include some protection off-screen coordinate when I next make changes to the engine and consider expanding the object handling functionality.
Binman - if memory serves, the Pumpkins demo automatically picks up any object with which the player comes into contact. You'll have to put the pick up code after an IF KEY. If you detect the gun, great, pick it up. If not, and you're carrying it, drop it.
Maybe it could be useful a hybrid add-on inbetween objects and sprites: DOORS. I mean doors which open once, if for example i have a key, but remain open when i return in the same room. Sprites removed reappear, and objects are put in the inventory! Doors simply could objects put on the screen following a dynamic permanence.
For the instance, i use variables which store 0/1 switches in order to decide if a door- sprite has to appear or not.
Maybe i can try "removeblock" instead, and build doors with blocks?
In Cronopios y Famas, in order to make certain objects disappear from the inventory when used, I employed this trick. The character sprite is briefly "sent" to a location of the screen, a 16x16 black ink/paper space inaccessible to the player. This is usually done by adding and/or subtracting a certain number to the current location of the character when it comes in contact with an invisible (empty) sprite.
The object is dropped with a PUT command, then the character sprite goes back to the same location as before, by returning to the previous coordinates.
In order to be effective, this technique requires that a separate key must be used to pick up/drop objects. It won't work when objects are made to be picked up instantly as soon as the character touches them.
an object must be given to another (non-player) character in the game. The player sprite faces the other character. If a series of conditions is met (screen number, object held, contact with the invisible sprite) the character coordinates are changed by subtracting 60 to the x co-ordinate. The sprite is then briefly brought to an empty (black ink and paper) inaccessible location in the screen and the object is dropped, then 60 is added to the x co-ordinate in order to bring the character back to its previous location. The object is still on the screen, but it can't be neither seen nor picked up again.
The process is so fast that the player won't ever notice it!
Last Edit: Jan 16, 2014 21:53:34 GMT by alessandro