Game similar to A Dark Room w/ Tkinter

Game similar to A Dark Room w/ Tkinter

Postby mckryall » Sun Mar 30, 2014 5:49 pm

I want to make a game similar to A dark room (http://adarkroom.doublespeakgames.com/ (CAUTION: Addicting and hard after a while)) with Tkinter and Python 2.7, on Mac OSX. I want to know how I could have slowly diminishing bars running alongside the normal game, and also the best way to make a bar in Tkinter (ASCII is fine). I'm not sure if I would have to run multiple python processes, but, if I do, I need to know how to execute them with one script and how to transfer data between them.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Game similar to A Dark Room w/ Tkinter

Postby metulburr » Sun Mar 30, 2014 9:36 pm

the best way to make a bar in Tkinter

Code: Select all
import math
import time
import sys

if sys.version[0] == '2':
    import Tkinter as tk
    import ttk
else:
    import tkinter as tk
    from tkinter import ttk

fileList = range(10)



def main():
    for fileName in fileList:
        # The sleeping represents a time consuming process
        time.sleep(1)
        print(fileName)

        # Update the progressbar
        progress.step(-step)
        progress.update()

    root.destroy()

root = tk.Tk()

width = 400
height = 200
x = math.trunc(root.winfo_screenwidth()/2-width/2)
y = math.trunc(root.winfo_screenheight()/2-height/2)
root.geometry('{w}x{h}+{x}+{y}'.format(w=width,h=height, x=x, y=y))

bar_len = 200
progress = ttk.Progressbar(root,orient ="horizontal",length = bar_len, mode ="determinate")
progress.pack()
progress["value"] = 100

# How much to increase by with each iteration
# This formula is in proportion to the length of the progressbar
step = math.trunc(100/len(fileList))

# Launch the loop once the window is loaded
progress.after(1, main)

root.mainloop()


and as for threads:
http://stackoverflow.com/questions/1335 ... ate-thread
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1470
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Game similar to A Dark Room w/ Tkinter

Postby mckryall » Sun Mar 30, 2014 9:41 pm

I really just wanted to know about transferring data between threads and making threads.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Game similar to A Dark Room w/ Tkinter

Postby Mekire » Sun Mar 30, 2014 11:49 pm

Threading seems completely unnecessary here. You should be able to do this with Frame.after(milliseconds, function) and just draw the needed size of rect every call (though I don't actually recommend doing game programming of any kind in tkinter).

If you really want to learn about threading (or probably more likely multiprocessing) try these tutorials:
http://pymotw.com/2/threading/index.html
http://pymotw.com/2/multiprocessing/index.html

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Game similar to A Dark Room w/ Tkinter

Postby mckryall » Mon Mar 31, 2014 1:48 am

I'm on a school computer and can't install packages, therefore no PyGame, and all of the PyGame files are written in C, so I can't manually install it.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Game similar to A Dark Room w/ Tkinter

Postby metulburr » Mon Mar 31, 2014 5:37 am

The easiest way to bypass a school computer is to put a linux distro on a usb stick and boot into that live. There was a way to save selected packages so you dont have to install the same package for each boot into live but i forgot the process. Chances are your school does not have windows 8 c0mputers so you dont have to deal with disabling secure boot, but you still need to rearrange the boot menu in bios to have the usb boot before the hdd. From that point on you have root access to the linux distro allowing you to do whatever you want. You also have access to their windows partition too. Whoops said too much.

EDIT:
another option would be to use portable python. It comes with IDLE, other 3rd party modules, including pygame. Its quite nice for jumping around a lot of public computers with various restrictions if all you are going to use is python/pygame.
NOTE: pygame comes with the 2.x one, not the 3.x one.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1470
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Game similar to A Dark Room w/ Tkinter

Postby mckryall » Mon Mar 31, 2014 12:11 pm

I'm on a school MacBook air, and I've tried to boot linux MANY times.
Python 2.7
Mac Mini
Laptop w/ Ubuntu 14.04
Steam; PSN
mckryall
 
Posts: 94
Joined: Sat Nov 23, 2013 6:13 pm

Re: Game similar to A Dark Room w/ Tkinter

Postby metulburr » Mon Mar 31, 2014 12:45 pm

New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1470
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Game similar to A Dark Room w/ Tkinter

Postby stranac » Mon Mar 31, 2014 1:08 pm

That's assuming you actually have the ability to choose how the computer will boot, which is pretty unlikely.
Security would have to be shit to allow that.

Something like portable python might be a good option, if you have the ability to run it.
Most student accounts around here are restricted so that only programs explicitly allowed by root/admin can be executed.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1144
Joined: Thu Feb 07, 2013 3:42 pm

Re: Game similar to A Dark Room w/ Tkinter

Postby metulburr » Mon Mar 31, 2014 4:10 pm

Most student accounts around here are restricted so that only programs explicitly allowed by root/admin can be executed.

wow that would suck. Our college public computers allows you to install anything (well i ahve not came across anything yet that i could not install), but resets itself at midnight every day.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1470
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest