stef
Menagerie
Posts: 9
|
Post by stef on Dec 5, 2020 12:14:58 GMT
Hello!
My first message here.
I've read several threads about objects but some of them date back to 2013 so maybe things have changed in the most recent release.
In my game in each screen you have to take an object and bring it to the exit.
What I'd like to do is make the taken object reset to its starting point when the player respawns, WITHOUT resetting the whole screen.
Is that possible?
Thanks a lot for your help.
|
|
stef
Menagerie
Posts: 9
|
Post by stef on Dec 5, 2020 12:31:38 GMT
Ok, of course minutes after posting the help request it seems that i managed to do this with a user routine. Used the jp iniob command and it seems to work. I'll do some more testing.
|
|
stef
Menagerie
Posts: 9
|
Post by stef on Dec 5, 2020 13:08:14 GMT
On the other hand I realized that if I need the same couple of item in each room (the object to be taken and the "exit") I need to repeat objects and code for each screen. Not a good solution.
Most probably I've got to go with sprites?
|
|
|
Post by Jonathan Cauldwell on Dec 5, 2020 18:47:06 GMT
Putting jp iniob in a user routine will reset all objects to their starting positions, regardless of the screen you are on, if that's what you want.
A user routine to reset a specific object could look like this (warning, this is untested):
; USER argument is passed to the user routine in the accumulator.
call findob ; find object details. ld d,h ; copy address to destination. ld e,l inc hl ; skip to initial position of object. inc hl inc hl ld bc,3 ; 3 bytes for screen, x and y. ldir ; copy to current status bytes. ret
|
|
|
Post by Jonathan Cauldwell on Dec 5, 2020 19:07:46 GMT
While I'm on the subject, if you wanted a user routine to put any item on a specified screen at a particular position try this one. Set the screen number up in A, the coordinates in B and C (Y and X respectively), then use USER n to put object n there. If the object is on screen you'll either have to have the player get it first or redraw the screen yourself after. Again, this is untested:
call findob ; find object details. ex de,hl ; make address our destination. ld hl,vara ; variables with new details. ld bc,3 ; 3 bytes for screen and position. ldir ; set new screen and position. ret
If you wanted to use (say) P, Q and R instead just change vara to varp.
|
|
stef
Menagerie
Posts: 9
|
Post by stef on Dec 5, 2020 20:57:59 GMT
Thanks a lot, I'm trying.
A thing that I don't understand well: the X and Y coordinates for objects are in pixel, not in blocks, right?
|
|