Can I make the picture associated with a hotspot random from a set of pictures each time a frame loads?
This is needed to create a card game I am working at.
A solution to this problem would be very much appreciated.
Please help me!
Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support
randomize
i = int( RND * number_of_total_images ) + 1
if i = 1 Then Action.LoadAPicture Hotspot(HOTSPOT_NUMBER), "FILENAME1"
if i = 2 Then Action.LoadAPicture Hotspot(HOTSPOT_NUMBER), "FILENAME2"
if i = 3 Then Action.LoadAPicture Hotspot(HOTSPOT_NUMBER), "FILENAME3"
... etc. until last image name is reached
dim selected(5)
dim counter
dim numbers(45)
for i=0 to 44
numbers(i)=i+1
next
do while counter<5
sel=false
randomize
rand=int(rnd*45)+1
for i=0 to 4
if selected(i)=rand then
sel=true
end if
next
if sel=false then
selected(counter)=rand
'numbers(rand-1)=0
counter=counter+1
end if
loop
for i=0 to 44
if i mod 5 = 0 then
text=text+vbcrlf
end if
text=text+cstr(numbers(i))+vbtab
next
text=text+vbcrlf+"Selected numbers: "
for i=0 to 4
text=text+cstr(selected(i))+", "
next
msgbox text,vbokonly,"Joker"
Sub SpotA
randomize
i = int( RND * 10 ) + 1
a = i
if a = 1 then Action.LoadAPicture Hotspot(1), "1.jpg"
if a = 2 then Action.LoadAPicture Hotspot(1), "2.jpg"
if a = 3 then Action.LoadAPicture Hotspot(1), "3.jpg"
if a = 4 then Action.LoadAPicture Hotspot(1), "4.jpg"
if a = 5 then Action.LoadAPicture Hotspot(1), "5.jpg"
if a = 6 then Action.LoadAPicture Hotspot(1), "6.jpg"
if a = 7 then Action.LoadAPicture Hotspot(1), "7.jpg"
if a = 8 then Action.LoadAPicture Hotspot(1), "8.jpg"
if a = 9 then Action.LoadAPicture Hotspot(1), "9.jpg"
if a = 10 then Action.LoadAPicture Hotspot(1), "10.jpg"
End Sub
Sub SpotB
Do Until i <> a
randomize
i = int( RND * 10 ) + 1
Loop
b = i
if b = 1 then Action.LoadAPicture Hotspot(2), "1.jpg"
if b = 2 then Action.LoadAPicture Hotspot(2), "2.jpg"
if b = 3 then Action.LoadAPicture Hotspot(2), "3.jpg"
if b = 4 then Action.LoadAPicture Hotspot(2), "4.jpg"
if b = 5 then Action.LoadAPicture Hotspot(2), "5.jpg"
if b = 6 then Action.LoadAPicture Hotspot(2), "6.jpg"
if b = 7 then Action.LoadAPicture Hotspot(2), "7.jpg"
if b = 8 then Action.LoadAPicture Hotspot(2), "8.jpg"
if b = 9 then Action.LoadAPicture Hotspot(2), "9.jpg"
if b = 10 then Action.LoadAPicture Hotspot(2), "10.jpg"
End Sub
Sub SpotC
Do Until i <> a and i <> b
randomize
i = int( RND * 10 ) + 1
Loop
c = i
if c = 1 then Action.LoadAPicture Hotspot(3), "1.jpg"
if c = 2 then Action.LoadAPicture Hotspot(3), "2.jpg"
if c = 3 then Action.LoadAPicture Hotspot(3), "3.jpg"
if c = 4 then Action.LoadAPicture Hotspot(3), "4.jpg"
if c = 5 then Action.LoadAPicture Hotspot(3), "5.jpg"
if c = 6 then Action.LoadAPicture Hotspot(3), "6.jpg"
if c = 7 then Action.LoadAPicture Hotspot(3), "7.jpg"
if c = 8 then Action.LoadAPicture Hotspot(3), "8.jpg"
if c = 9 then Action.LoadAPicture Hotspot(3), "9.jpg"
if c = 10 then Action.LoadAPicture Hotspot(3), "10.jpg"
End Sub
Sub SpotD
Do Until i <> a and i <> b and i <> c
randomize
i = int( RND * 10 ) + 1
Loop
d = i
if d = 1 then Action.LoadAPicture Hotspot(4), "1.jpg"
if d = 2 then Action.LoadAPicture Hotspot(4), "2.jpg"
if d = 3 then Action.LoadAPicture Hotspot(4), "3.jpg"
if d = 4 then Action.LoadAPicture Hotspot(4), "4.jpg"
if d = 5 then Action.LoadAPicture Hotspot(4), "5.jpg"
if d = 6 then Action.LoadAPicture Hotspot(4), "6.jpg"
if d = 7 then Action.LoadAPicture Hotspot(4), "7.jpg"
if d = 8 then Action.LoadAPicture Hotspot(4), "8.jpg"
if d = 9 then Action.LoadAPicture Hotspot(4), "9.jpg"
if d = 10 then Action.LoadAPicture Hotspot(4), "10.jpg"
End Sub
SpotA
SpotB
SpotC
SpotD
Sub SpotA
randomize
i = int( RND * 10 ) + 1
a = i
Action.LoadAPicture Hotspot(1), cstr(a)+".jpg"
End Sub
Sub SpotB
Do Until i <> a
randomize
i = int( RND * 10 ) + 1
Loop
b = i
Action.LoadAPicture Hotspot(2), cstr(b)+".jpg"
End Sub
Sub SpotC
Do Until i <> a and i <> b
randomize
i = int( RND * 10 ) + 1
Loop
c = i
Action.LoadAPicture Hotspot(3), cstr(c)+".jpg"
End Sub
Sub SpotD
Do Until i <> a and i <> b and i <> c
randomize
i = int( RND * 10 ) + 1
Loop
d = i
Action.LoadAPicture Hotspot(4), cstr(d)+".jpg"
End Sub
lisbonsasori wrote:I think there is a consideration to be made regarding your approach.
It will work fine if your images are named precisely as the ones in my previous example.
But images can be named anything and if they have any different name the Action.LoadAPicture Hotspot(), cstr()+".jpg? function will not work.
So, one must always be sure to rename the images accordingly.
Return to Adventure Maker Technical Support and Bug Reports
Users browsing this forum: No registered users and 0 guests