Jump to content
  • Advertisement

Clockworking

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

142 Neutral

About Clockworking

  • Rank
    Member
  1. Clockworking

    Amusing glitch gallery

    Tried my hand at 3D graphics today, not sure if its a problem with the model I have, or with Panda3D.  
  2. Clockworking

    Best comment ever

      Maybe the jerk should have spent less time trying to be the next Shakespeare and refactored the code.  Sheesh.   Well yeah, i could have done that too, but it seemed more fun to write a uselessly long comment for a really badly coded program that will most likely never make it onto the internet.
  3. Ohhhhh, okay. I was taught not to use the parenthesis on print statements (did I overlook something else?) , i'll take note of that.   EDIT: Parenthesis didn't do anything, it's still refusing to load the data to system_var.texts_one   ANOTHER_EDIT: Actually, I found the issue, it turns out I never set up the language controller to accept the new name of english1.lang instead of the old eng1.lang. I can't believe it took me this long to realize there was a difference in the filenames. class filemanager: #How we manage our files. Use appropriate extension in selection. @staticmethod def info(selection, mode, data = ['NONE']): # We first enter the right mode. if mode == 'read': #Open the selected file data1 = open(selection, 'r') # Check which file is being manipulated. if selection == 'userdata.cfg': try: system_var.username = data1.readline() # Username. system_var.password = data1.readline() # Password. except IOError: exit() elif selection == 'config.cfg': try: system_var.language = data1.readline(1) # Language Selection. except IOError: exit() elif selection == 'eng1.lang' or 'eng2.lang': if selection == 'eng1.lang': try: for line in data1.readlines(): system_var.texts_one.append(line.strip(line)) except IOError: exit() else: try: system_var.texts_two = data1.read() except IOError: exit() else: exit() elif mode == 'write': data1 = open(selection, 'r+') if selection == 'userdata.cfg': data1.write(system_var.usrname + '\n' + system_var.passwrd) else: exit() data1.close() # Variables. class system_var: usrname = 'NAN' username = 'NAN' passwrd = 'NAN' password = 'NAN' langugages = ['english'] language_selection = 'english' osname = os.name osplat = platform.system() texts_one = [] filemanager.info('english.lang', 'read') print (system_var.texts_one[0])
  4. Clockworking

    Best comment ever

    I've been pondering this one for a bit, not really meant to be funny, just something my brain churned out from the deep dark recesses of my puberdescent teenage mind. '''This code is utterly useless, I don't even know why you're trying to figure it out, it doesn't work! If your still reading this comment that means your soul must have been eaten by the horrendous clusterfuck that created the prior class of 123 lines which tangles everything so horridly it is incomprehensible. Don't even try and read what's below because all the comments are trolls and the code will require TWO supercomputers which have been given steroids to figure out. You will never make it out of here. May the computer gods and their goats bless your geeky soul, and may your brain not melt into goo.''' I am seriously considering sticking this into an old BASH file I have. I dont remember the format for multi-line comments but a little research will turn something up.   EDIT: It appears despite me only being 16, programming is already slowly driving me insane.
  5. I wrote some code up today between classes, it's the start of a text RPG game (Or maybe some type of software client? I don't know yet) and right now the code is messy because i'm too busy manually checking other stuff and swapping out code to get language file loading to work right. It's becoming a nightmare to work on using the Chromebook I have to use. Maybe pulling it up in Pycharm at home will allow me to fix it up and make it pretty?   Essentially i'm using the info command in sys_control to load different data, and python doesn't like loading values from files to lists for some reason. (If anyone knows how I can get this working, please let me know, I have been working on that for the past two hours.) import fcntl import termios import struct import os import platform import time # Things such as error handling. class system_control: @staticmethod def error(id = 0): if isinstance(id, int) is True: try: print system_var.errors[id + 1][0] if system_var.errors[id + 1][1] is True: exit() except IndexError: print system_var.errors[0][0] exit() else: print system_var.errors[0][0] exit() # A console formating class, makes the game look pretty. class console: @staticmethod # A function retrieved from http://stackoverflow.com/questions/566746/ # how-to-get-console-window-width-in-python. I'll try my best to document the # code for the code, i renamed it to getdimensions def getdimensions(dimension): env = os.environ def ioctl_GWINSZ(fd): try: cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) except: return return cr cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = ioctl_GWINSZ(fd) os.close(fd) except: pass if not cr: cr = (env.get('LINES', 25), env.get('COLUMNS', 80)) ### Use get(key[, default]) instead of a try/catch #try: # cr = (env['LINES'], env['COLUMNS']) #except: # cr = (25, 80) if dimension.lower() == 'width' or 'x': return int(cr[1]) elif dimension.lower() == 'length' or 'y': return int(cr[2]) else: return int(cr[1]), int(cr[0]) # Centers text @staticmethod def centered(text): # Get the whole screen width and convert it to half of that. difference = console.getdimensions('x') / 2 # subtract new width by length of string to get the centering value. difference = difference - len(text) # return the input, centering it using the new width. return text.center(difference, ' ') # Clears the screen @staticmethod def clear(): if system_var.osplat == 'Linux': os.system('clear') elif system_var.osplat == 'Windows': os.system('cls') else: system_control.error(1) # A data managing class to make things easier. class filemanager: #How we manage our files. Use appropriate extension in selection. @staticmethod def info(selection, mode, data = ['NONE']): # We first enter the right mode. if mode == 'read': #Open the selected file data1 = open(selection, 'r') # Check which file is being manipulated. if selection == 'userdata.cfg': try: system_var.username = data1.readline() # Username. system_var.password = data1.readline() # Password. except IOError: system_control.error(4) elif selection == 'config.cfg': try: system_var.language = data1.readline(1) # Language Selection. except IOError: system_control.error(4) elif selection == 'eng1.lang' or 'eng2.lang': if selection == 'eng1.lang': try: for line in data1.readlines(): system_var.texts_one.append(line.strip()) except IOError: system_control.error(4) else: try: system_var.texts_two = data1.read() except IOError: system_control.error(4) else: system_control.error(3) elif mode == 'write': data1 = open(selection, 'r+') if selection == 'userdata.cfg': data1.write(system_var.usrname + '\n' + system_var.passwrd) else: system_control.error(0) data1.close() # Variables. class system_var: usrname = 'NAN' username = 'NAN' passwrd = 'NAN' password = 'NAN' langugages = ['english'] language_selection = 'english' osname = os.name osplat = platform.system() errors = [ ['ERROR: Invalid ID reported to error handler. (00-00)', True], ['ERROR: Invalid mode for the data manager. (00-01)', True], ['ERROR: Operating System is not supported. (00-02)', True], ['ERROR: Invalid language setting, assuming language to be English. (00-03)', False], ['ERROR: Terminating for safety, an invalid file selection (00-04)', False], ['ERROR: Unable to continue, a file is missing! (00-05)', True] ] texts_one = [] # Initial class for game. class startgame: @staticmethod def login(): filemanager.info('userdata.cfg', 'read') print console.centered(system_var.texts_one[0]) if len(system_var.username) > 0: system_var.usrname = raw_input(system_var.texts_one[2]) system_var.passwrd = raw_input(system_var.texts_one[4]) if system_var.usrname == system_var.username: if system_var.passwrd == system_var.password: startgame.load() else: print "Username and/or password are incorrect" startgame.login() else: print "Username and/or password are incorrect" startgame.login() else: system_var.usrname = raw_input(system_var.texts_one[1]) system_var.passwrd = raw_input(system_var.texts_one[3]) filemanager.info('userdata.cfg', 'write') @staticmethod def load(): if system_var.language_selection == 'english': print 'Loading game, please wait...' languagecache = str(system_var.language_selection) + '1.lang' print 'loading ' + languagecache filemanager.info(languagecache, 'read') else: system_control.error(2) system_var.language_selection = 'english' startgame.load() startgame.login() @staticmethod def __init__(): print "Operating System: " + str(system_var.osplat) + " (" + str(system_var.osname) + ")" if system_var.osplat == 'Linux' or 'Windows': print "Operating System verified as supported." time.sleep(3) console.clear() startgame.load() else: system_control.error(1) startgame.__init__()
  6. Clockworking

    Code appearance, is it really important?

    The only time it's fine to not have pretty code is when you DON'T want other people to know what it does. Otherwise, be sure to keep it neat and tidy and use plenty of comments!   Good code is as simple as possible as it's purpose will allow. It should be clean, tidy, and most importantly has comments except in places except for where it should be quite obvious what a segment of code is trying to do. Code not only is a form of writing, but also a machine that needs to be easy to maintain and work on.
  7. Thank you Glportal, I believe this will help me with what I am wanting to do.
  8. Hey guys, it's me again and I have another question:   After messing around with Tkinker to create a chat client GUI in python on my Linux machine at home (Experimenting with multiprocessing), I want to do the same on my school's Chromebook, but using a module to access the JavaScript functions I have on the webpage, OR directly manipulate the HTML of the webpage the GUI will be displayed on, along with calling python functions using buttons that I will have on the page, and accessing any JavaScript variables I may have.   Is there any way to do this?   EDIT: I'm also hoping to create a simple module to allow people to create GUIs if they're on a Chromebook.
  9. Clockworking

    Looking for a ChromeOS based Python IDE for school

    Yeah, I've been holding out on an IDE called Nitrous, I can debug but it requires me to run the same BASH command over and over on the console it uses to display your program in action. I'll check out PyCharm and Komodo, although I didn't think PyCharm could run on a Chromebook, at least without booting an external HDD with Linux   To be honest I wish I could just take my external HDD and boot my Ubuntu install on my Chromebook but the school IT guys blocked the CroSH shell so I don't have the minimum access requirements to do that. My home computer is on it's last legs, and I'm getting a new one in February. I can then abandon the cloud IDE and stream my desktop to my Chromebook at school.
  10. (Woo first post! :D)   Hello, I have been programming since I first hit double digits. I am in high school taking a coding class and I finally got on the Python boat. However I have a problem, I will be needing a proper IDE for the Chromebooks we use at my school in order to further polish my skills in this class.   Does anyone know of an IDE that I could use? I've looked at the Chrome web store and haven't had much luck looking for one that actually works.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!