20 numbers

Support for version 4.9 and earlier.

20 numbers

Postby Ruffsta » May 24th, 2011, 3:27 pm

k, what i'm attempting to do is this:

20 numbers must be randomly drawn/generated.. no duplicates

the range of numbers is 1-80
Ruffsta
 
Posts: 44
Joined: March 3rd, 2011, 1:29 pm

Re: 20 numbers

Postby JanMulder » May 24th, 2011, 4:11 pm

Ruffsta,

Why don't you code those things yourself. I PMed you something similar which works. Can't you understand from that how to do this?

Jan.
here and yet not here
JanMulder
 
Posts: 726
Joined: December 30th, 2010, 3:08 pm

Re: 20 numbers

Postby Ruffsta » May 24th, 2011, 4:15 pm

first, i lost all of my old pm's cause they were deleted somehow..

secondly, this has nothing to do with the other thing you are talking about - they are 2 totally different projects

this one is for keno, the other is for a map game..
Ruffsta
 
Posts: 44
Joined: March 3rd, 2011, 1:29 pm

Re: 20 numbers

Postby YoshiInAVoid » May 24th, 2011, 4:25 pm

Here you go:
viewtopic.php?f=27&t=1633
Ten variables, all aranged in a different order, if you scroll down, someone posts a working example.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: 20 numbers

Postby Ruffsta » May 24th, 2011, 10:06 pm

yeah that didn't work... i know i made that topic..
Ruffsta
 
Posts: 44
Joined: March 3rd, 2011, 1:29 pm

Re: 20 numbers

Postby YoshiInAVoid » May 25th, 2011, 9:15 am

Cilien posted working code.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: 20 numbers

Postby Ruffsta » May 30th, 2011, 7:49 pm

k, i have this and it draws 20 numbers 1 through 80..

ACT Room_3,X PAlib bool used[80]
ACT Room_3,X PAlib int randomnumbers[20]
ACT Room_3,Declare Global finished;Boolean (true/false);0
ACT Room_3,Declare Global loop;8-bit Unsigned;0
ACT Room_3,Declare Global random;8-bit Unsigned;0
ACT Room_3,Do Just once
ACT Room_3,While loop != 20
ACT Room_3,While !finished
ACT Room_3,Set Variable random;PA_RandMinMax(1,80)
ACT Room_3,Immediate If !used[random];finished = 1
ACT Room_3,Set Variable used[random];1
ACT Room_3,End While
ACT Room_3,Set Variable finished;0
ACT Room_3,Set Variable randomnumbers[loop];random
ACT Room_3,Draw Variable 1;0;loop;random
ACT Room_3,Set Variable loop;loop+1
ACT Room_3,End While
ACT Room_3,Set Variable loop;0

however.. what i want it to do now is if let's just say for argument sake that the number "1" was drawn in any of the 20 numbers drawn that something happens.. i tried the following and none work:

A:
ACT Room_3,If (randomnumbers[0]== 1 || randomnumbers[1]== 1 || randomnumbers[2]== 1 || randomnumbers[3]== 1 || randomnumbers[4]== 1 || randomnumbers[5]== 1 || randomnumbers[6]== 1 || randomnumbers[7]== 1 || randomnumbers[8]== 1 || randomnumbers[9]== 1 || randomnumbers[10]== 1 || randomnumbers[11]== 1 || randomnumbers[12]== 1 || randomnumbers[13]== 1 || randomnumbers[14]== 1 || randomnumbers[15]== 1 || randomnumbers[16]== 1 || randomnumbers[17]== 1 || randomnumbers[18]== 1 || randomnumbers[19]== 1) && PA_GetSpriteAnimFrame(0,0) == 80
ACT Room_3,Set Sprite Frame 0;0;160
ACT Room_3,Set Variable hits;hits + 1
ACT Room_3,Else If PA_GetSpriteAnimFrame(0,0) == 0
ACT Room_3,Set Sprite Frame 0;0;240
ACT Room_3,End If


B:
ACT Room_3,Loop i,1,80
ACT Room_3,If randomnumbers[i]== 1 && PA_GetSpriteAnimFrame(0,0) == 80
ACT Room_3,Set Sprite Frame 0;0;160
ACT Room_3,Set Variable hits;hits + 1
ACT Room_3,Else If PA_GetSpriteAnimFrame(0,0) == 0
ACT Room_3,Set Sprite Frame 0;0;240
ACT Room_3,End If
ACT Room_3,End Loop

basically i'm making a KENO game, and as i mentioned for arguments sake that if "1" was drawn in any of the 20 numbers AND if "1" was selected on the board then change the YELLOW 1 to a green 1, otherwise if the 1 was not selected on the board but was drawn in the 20 numbers then change the BLUE 1 to a RED one..

at the moment, the YELLOW 1 changes to a GREEN 1 even if it's not one of the 20 numbers drawn or to a RED 1 if it was drawn but not selected on the board.. no matter what code i put in there - it's not doing exactly what i want it to do :(

keno1.PNG
keno1.PNG (17.54 KiB) Viewed 1019 times
Ruffsta
 
Posts: 44
Joined: March 3rd, 2011, 1:29 pm

Re: 20 numbers

Postby YoshiInAVoid » June 3rd, 2011, 7:54 pm

Your code comfuses me.

You have this:
Code: Select all
&& PA_GetSpriteAnimFrame(0,0) == 80

But I see no code that sets the sprites frame to 80, so the if will never happen.

Please may I have your pack and go so as I can see more what is going on, and I can make minor changes and see if I can get it to function correctly.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: 20 numbers

Postby Ruffsta » June 3rd, 2011, 7:59 pm

ah, yeah that part of the code is in another room... check your pm for the pack n' go
Ruffsta
 
Posts: 44
Joined: March 3rd, 2011, 1:29 pm

Re: 20 numbers

Postby YoshiInAVoid » June 4th, 2011, 4:16 pm

Ahaha! I have fixed it for you Ruffsta!

I have fixed all the buttons that didn't work, but left the ones you haven't yet attempted; but if you have problems with them, give me another PM and I'll fix that up for you as well.

I hope this is what you wanted me to do, check your PM box for the new pack and go!
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England


Return to DSGM 4.9

Who is online

Users browsing this forum: No registered users and 1 guest