Random Pop-Ups
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Random Pop-Ups
I have about 20-30 pop up graphics that i would like to pop up randomly through out the game. The game is a really simple shooting game and every time you shoot the score goes up by 1. I would be ok with having these pop ups show up every 5 or so. They can should also stay up until the next one pops up. Any help would be great.
Re: Random Pop-Ups
Hi Wayne,
OK, at what part exactly are you needing help?
Randomize the locs of the graphics?
Showing/hiding graphics?
Memorizing the current "pop-up" graphic in a local of global variable (or custom property) and hide that one when the next one pops up?
"send" a command every X seconds?
Best
Klaus
OK, at what part exactly are you needing help?
Randomize the locs of the graphics?
Showing/hiding graphics?
Memorizing the current "pop-up" graphic in a local of global variable (or custom property) and hide that one when the next one pops up?
"send" a command every X seconds?
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
How to show a random pop up every 5 points.
I have them in the locations they should be in and set the visible off.
I have them in the locations they should be in and set the visible off.
Re: Random Pop-Ups
Hi Wayne,
OK, here a "fake" script that should get you started:
Best
Klaus
OK, here a "fake" script that should get you started:
Code: Select all
local the_last_popup
## Will store the name or ID of the last popup graphic
command los_popups
if the_last_popup <> empty then
hide img the_last_popup
end if
## Show a random image.
## You might need to maintain a list of these images somewhere,
## so you cann access it and "pull" out a random image
show img XYZ
put XYZ into the_last_popup
## Now you need a conditon to NOT show an image anymore:
if your_condtion_here = true then
exit los_popups
end if
## The show goes on in 5 secs:
send "los_popups" to me in 5 secs
end los_popups
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
So i have:
1.jpg
2.jpg
3.jpg
4.jpg
Up to 30.jpg
I want nothing to show up for the first 5 points than at 5 it would randomly pick one of my jpg's, then at every 5 points it would randomly pick another of the jpg's to appear and stay up for the next 5 points.
1.jpg
2.jpg
3.jpg
4.jpg
Up to 30.jpg
I want nothing to show up for the first 5 points than at 5 it would randomly pick one of my jpg's, then at every 5 points it would randomly pick another of the jpg's to appear and stay up for the next 5 points.
Re: Random Pop-Ups
...then you should use the script (or parts of it) in your "point calculation" routine:
...
if totalpoints = 5 then...
...
You get the picture!
Best
Klaus
...
if totalpoints = 5 then...
...
You get the picture!
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
I am still really lost. I tried all the tricks i had and nothing is working.
Re: Random Pop-Ups
Wayne,
what do you have so far? What did you try so far?
Best
Klaus
what do you have so far? What did you try so far?
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
this is where I left off yesterday:
If field "score" =(x)5 then
place random 150, 180 (1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg)
end if
If field "score" =(x)5 then
place random 150, 180 (1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg)
end if
Re: Random Pop-Ups
Hi Wayne,
well, this is indeed meager!
Please post more infos, scripts etc. if you don't want to last this until christmas
I am sure you already looked up the terms "place" and "random()" to understand why that snippets does not work, right?
"place" will place GROUPS or Backgrounds onto a card
"random" is a function and needs a parameter that can be "randomized"
As far as I understood so far you already have these images on the correct card but all images are hidden so far, right?
So you need to show/hide these images when a certain conditon happens.
Where did you try to add this snippet?
What does "150,180" mean in your snippet?
As I wrote in an earlier mail you should "hook" into the "points calculating" handler that you have (if any).
Please explain what you want to do to yourself (and us) in PLAIN english and I bet you will be able to translate it almost 1:1 to LiveCode.
Again I think your are thinking far too complicated!
Like this:
When the points are at least 5 or a multiple of 5 (right?) then I want ...
Best
Klaus
well, this is indeed meager!

Please post more infos, scripts etc. if you don't want to last this until christmas

I am sure you already looked up the terms "place" and "random()" to understand why that snippets does not work, right?
"place" will place GROUPS or Backgrounds onto a card
"random" is a function and needs a parameter that can be "randomized"
As far as I understood so far you already have these images on the correct card but all images are hidden so far, right?
So you need to show/hide these images when a certain conditon happens.
Where did you try to add this snippet?
What does "150,180" mean in your snippet?
As I wrote in an earlier mail you should "hook" into the "points calculating" handler that you have (if any).
Please explain what you want to do to yourself (and us) in PLAIN english and I bet you will be able to translate it almost 1:1 to LiveCode.
Again I think your are thinking far too complicated!
Like this:
When the points are at least 5 or a multiple of 5 (right?) then I want ...
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
Sorry, I am making it more complicated than it need to be. I added this to the card script.
Here it is broken down:
I have 30 images (1-30.jpg) set at the same spot (150,180). they are all set to not visible on the card. When the score hits a multiple of 5 i would like it to randomly display 1 of the 30 images that are hidden and stay visible until the next multiple of 5.
Here it is broken down:
I have 30 images (1-30.jpg) set at the same spot (150,180). they are all set to not visible on the card. When the score hits a multiple of 5 i would like it to randomly display 1 of the 30 images that are hidden and stay visible until the next multiple of 5.
Re: Random Pop-Ups
Hi Wayne,
aha, we are moving along
Do you have a handler that counts your points?
We could and SHOULD hook intot that scripts!
I would use a BUTTON and just set its ICON to the ID of your image!
This way you do not need to hide a previously shown image!
Set the loc of this button to 150,180 and that's it (almost)
This needs some preparation: a list of the IDs of your images, preferrably CR delimited, ONE id per line!
Then you can simply:
Get the picture?
I would add this to your "points calculation and display" handler after actually setting the points.
Best
Klaus
aha, we are moving along

Do you have a handler that counts your points?
We could and SHOULD hook intot that scripts!
I would use a BUTTON and just set its ICON to the ID of your image!
This way you do not need to hide a previously shown image!
Set the loc of this button to 150,180 and that's it (almost)

This needs some preparation: a list of the IDs of your images, preferrably CR delimited, ONE id per line!
Then you can simply:
Code: Select all
...
if (total_points >= 5) AND (total_points mod 5 = 0) then
## Greater than 5 AND a multiple of 5!
set the ICON of btn "your button that shows the images here" to ANY line of list_with_image_IDs
## or: .. ANY line of fld "list_with_image_IDs" or wherever you decide to store this info
end if
...
I would add this to your "points calculation and display" handler after actually setting the points.
Best
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
I am 98% with you. I have a field called "score" holding the points.
This is what is tripping me up:
This is what is tripping me up:
how do i make the list?This needs some preparation: a list of the IDs of your images, preferrably CR delimited, ONE id per line!
Re: Random Pop-Ups
Hi Wayne,
you could do this manually, select the images and look up their ID in the Inspector palette or use a little script to do so:
Best
Klaus
you could do this manually, select the images and look up their ID in the Inspector palette or use a little script to do so:
Code: Select all
...
put empty into tIDList
repeat with i = 1 to 30
put i & ".jpg" into tImageName
## This requires that all images are on the card where you execute this script or you get an error "Object not found..."!
## Otherwise you need to add a decriptor:
### ... of img tImageName OF CD X ## of stack Y
put the ID of img tImageName & CR after tIDList
end repeat
## Get rid of trailing CD
delete char -1 of tIDList
put tIDList into fld "ID list"
## or whereever...
...
Klaus
-
- Posts: 37
- Joined: Tue Apr 05, 2011 9:58 pm
Re: Random Pop-Ups
Sorry. I have to learn to be more clear.
Where do i make the list?
SO now i have a button at 150, 180 where do i list the IDs of my images? "list_with_image_IDs"
Where do i make the list?
SO now i have a button at 150, 180 where do i list the IDs of my images? "list_with_image_IDs"