May-17-2020, 01:40 PM
Python V3.72
Windows 7\Linux Mint 19.1
A game I am working on called Freespin Frenzy
crashes after a while with either an "out of memory"
message in the shell, or a "Python has stopped working" pop up,
this is in Windows 7.
The memory is getting eaten up fast by a bad piece of my code that
"spins" the reels, it doesn't actually spin them,
it just flashes all the symbols on top of each other for a short while.
I am sure I am approaching this all wrong, but this is the best
I can do at my current ability level.
Please look at this piece of the code below and see if you can advise me
on how to load in and use the graphics in a way that will
not use up RAM in about 30 mins of play, (I have 8gig ram).
You can get the full source code here if you want:
https://stevepython.wordpress.com/2020/0...-79-update
The game is still a work in progress and I hope to make it look a lot
better in future updates, but I have to get this fixed first really.
Regards, Steve.
Windows 7\Linux Mint 19.1
A game I am working on called Freespin Frenzy
crashes after a while with either an "out of memory"
message in the shell, or a "Python has stopped working" pop up,
this is in Windows 7.
The memory is getting eaten up fast by a bad piece of my code that
"spins" the reels, it doesn't actually spin them,
it just flashes all the symbols on top of each other for a short while.
I am sure I am approaching this all wrong, but this is the best
I can do at my current ability level.
Please look at this piece of the code below and see if you can advise me
on how to load in and use the graphics in a way that will
not use up RAM in about 30 mins of play, (I have 8gig ram).
You can get the full source code here if you want:
https://stevepython.wordpress.com/2020/0...-79-update
The game is still a work in progress and I hope to make it look a lot
better in future updates, but I have to get this fixed first really.
Regards, Steve.
def spin_reels(): """Pseudo spin,pretty poor, but best I can do for now.""" spinner = ['FH', 'FD', 'FC', 'WH', 'WD', 'WC', 'JH', 'JD', 'JC', 'JS', 'QH', 'QD', 'QC', 'QS', 'KH', 'KD', 'KC', 'KS', 'AH', 'AD', 'AC', 'AS', 'BH', 'BD', 'BC'] r_one = Label(cards_frame) r_two = Label(cards_frame) r_three = Label(cards_frame) Glo.hold_btn1.configure(state=DISABLED) Glo.hold_btn2.configure(state=DISABLED) Glo.hold_btn3.configure(state=DISABLED) for spins in range(4): for spinr in range(18): rnd_symb1 = randrange(len(spinner)) symb1 = spinner[rnd_symb1]+'.png' rnd_symb2 = randrange(len(spinner)) symb2 = spinner[rnd_symb2]+'.png' rnd_symb3 = randrange(len(spinner)) symb3 = spinner[rnd_symb3]+'.png' if spins < 1 and not Glo.btn1_is_held: r_one = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(symb1)) r_one.config(image=PHOTO) r_one.grid(row=0, column=1, padx=2, pady=2) r_one.photo = PHOTO r_one.update() if spins == 1 and not Glo.btn1_is_held: card_lbl_one = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(Glo.reel_one)) card_lbl_one.config(image=PHOTO) card_lbl_one.grid(row=0, column=1, padx=2, pady=2) card_lbl_one.photo = PHOTO r_one.update() if spins < 2 and not Glo.btn2_is_held: r_two = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(symb2)) r_two.config(image=PHOTO) r_two.grid(row=0, column=2, padx=2, pady=2) r_two.photo = PHOTO r_two.update() if spins == 2 and not Glo.btn2_is_held: card_lbl_two = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(Glo.reel_two)) card_lbl_two.config(image=PHOTO) card_lbl_two.grid(row=0, column=2, padx=2, pady=2) card_lbl_two.photo = PHOTO r_two.update() if spins < 3 and not Glo.btn3_is_held: r_three = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(symb3)) r_three.config(image=PHOTO) r_three.grid(row=0, column=3, padx=2, pady=2) r_three.photo = PHOTO r_three.update() if spins == 3 and not Glo.btn3_is_held: spins = 99 card_lbl_three = Label(cards_frame) PHOTO = PhotoImage(file='cards/gfx/'+str(Glo.reel_three)) card_lbl_three.config(image=PHOTO) card_lbl_three.grid(row=0, column=3, padx=2, pady=2) card_lbl_three.photo = PHOTO r_three.update() time.sleep(0.025) r_one.destroy() r_two.destroy() r_three.destroy() rnd_hold() check_for_win() save_bank()