Image able to update after a event happens

I am new to Inform 7 and I am currently reading Aaron Reed’s book ‘Creating Interactive Fiction with Inform 7’. So I have a little understanding of Inform 7. So here goes the question. If I have a image showing what the room looks like (using the multimedia extension) and the image has the objects that are listed in the room description and I take a item away can I have it so the image updates as well? Basically showing in the image that the item is no longer there. If I need to clarify more I would be happy to do so.

Thank You
InsertCoin25

First, decide exactly what sorts of things you want to change the image. Then, use a rule that will apply to those circumstances. For example, if you just want to change the image when the player takes a certain thing, it’s as simple as After taking the whatever-it-is: [tab][code to change the image, specific to the extension you're using]; [tab]continue the action. Whereas if you want to be sure that any action that removes the whatever-it-is from the room triggers the image change (whether it’s taken by a Non Player Character, or it melts away, or someone hides it in a box), you might want something more like Every turn: [tab]if the whatever-it-is is not in the room-it-was-in: [tab][tab][image-changing code, as before] So if you can be more specific about the conditions provoking the change, that might be enough to make it easier for you to find your answer in the documentation, and it will definitely help us give you a less-buggy answer.

Thanks for the reply tove. Example of condition: Player takes hammer off the table (image updates to show hammer is no longer on table). Another condition after taking hammer: Player uses hammer on a vase (destroying the vase) image updates again showing the vase destroyed and hammer not on table. I hope this helps a little.

Thanks
InsertCoin25

InsertCoin25, what is the multimedia extension you are referring to? Simple Graphical Window? It’s possible to do the kind of thing you want to do with simple image display (such as you get with the built-in figure display phrase, or the default image display rule in Simple Graphical Window), but you will need many duplicate images–for example, you’ll have to create one full image showing the room with the hammer, and one showing the room with the hammer removed. There will be lots of variants if you want to illustrate more than one item per room, e.g.: (1) hammer, no vase; (2) vase, no hammer; (3) hammer, broken vase; (4) no hammer, broken vase.

I think what you want is a better fit for the Glimmr extensions, since what you really want is to be able to display some images (a hammer) independently of others (the room); in other words, you want to display sprites. The Glimmr Canvas-Based Drawing extension is the main one you’d be working with, but while it includes many examples, none of them deal with precisely this set of circumstances. You can check out the Glimmr blog, though, to get some sense of what Glimmr does and how it works.

There are lots of ways to structure the code to control whether a sprite is displayed or not. Which is best depends on the specific circumstances and the details of what you’re trying to achieve. For example, will each object only be shown in one image? Or will you potentially show every object in every room? Those two circumstances will have very different requirements.

–Erik

I was thinking more along the lines of making duplicate images, but if I can make a blank room image and incorporate many sprites to fill the blank room image then I would go that route. I do not know if the Glimmr extension allows me to set sprites at a certain x,y point onto a image. Basically making the sprites transparent and allowing them to overlap the blank room image (thus making the room look full of objects). If this option is not possible I will go the duplicate image way. Is there a way to erase a image when a new image appears or do they just overlap each other (using the duplicate image option)?

Thanks
InsertCoin25

Sure, you can place as many sprites as you like at any coordinates you like.

–Erik

This is great news :smiley:. Does this also mean I can change any given sprite image into another sprite image? Example: Sprite of vase (not broken) - vase gets hit with a object - sprite changes to vase broken.

Thanks
InsertCoin25

Yes. The Canvas-Based Drawing extension regards a “sprite” as a kind of container placed at a given set of coordinates (but free to move); you can change the actual image displayed as you like. The compass rose exit lister example on the blog swaps out images to indicate whether the room in a given direction has been visited or not, while the canvas editor uses swapping to implement on and off states for buttons.

–Erik

This is a excellent tutorial ektemple :smiley: Thanks for the info and keep up the great work on Glimmr. Will be working with this extension for a while so I guess its time to learn as much as possible to get my project in full swing. Thanks again… :smiley:

InsertCoin25