Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Munchor

Pages: 1 ... 107 108 [109] 110 111 ... 424
1621
The Axe Parser Project / Re: Axe Library : AxeLib7
« on: May 09, 2011, 03:28:18 pm »
aeTIos: This is a library, lots of Labels that can be used by including or not the subprogram and then called is a library.

1622
TI Z80 / Re: xy
« on: May 09, 2011, 08:48:17 am »
Scout: not yet. I'd like to perfect the engine before I put anything new in it.

Yeah that's the way to go :D

1623
Computer Projects and Ideas / Re: My math project
« on: May 09, 2011, 08:30:17 am »
Oh great, also constants (like maximum and minimum) should be right after imports :D

I didn't change anything else because I was not sure if maximum and minimum were constants.

1624
Computer Programming / Re: IRC Score Bot
« on: May 09, 2011, 08:20:54 am »
I am aware that it is not yet in the channel, but if it is going to be in the channel, then it should account for users posting through omnom. That's all I was saying.

Oh yeah that will work no problem :D

1625
TI Z80 / Re: The Chosen
« on: May 09, 2011, 07:53:02 am »
BASIC + xLib.
Always mah favorite XD

Im making a database of mobs and magic right now, so i'll post screenshot after im done with monsters XD

Oh xLib, shiny :D

1626
Web Programming and Design / Re: A·Map - Online Tilemap Editor
« on: May 09, 2011, 07:47:48 am »
I love online utilities, great Aishi!

1627
TI Z80 / Re: asmdream is waking up...
« on: May 09, 2011, 07:45:17 am »
Wow... What a post rush =]

No disassembler.
Not even a typer.
Just a compiler which reads sources written directly using the os prgm editor.

Ah OS PRGM Editor, looking good too :D This will shorten the code.

1628
Computer Projects and Ideas / Re: My math project
« on: May 09, 2011, 07:44:52 am »
ruler501, I haven't even tried it but I have a few recommendations on the code (also very good boy, using 4 spaces :)).

Code: [Select]
import sys
import os
import pygame
import random
from math import *
from pygame.locals import *

#Check to see if pygame is working right
#check font
if not pygame.font:
    print 'Warning, fonts disabled'
#check sound
if not pygame.mixer:
    print 'Warning, sound disabled'

minimum=12.17
maximum=17.43

def calc_amount(doubling):
    newval=2
    rate=log(2)/doubling
    valueatpoint=[2,]
    num=0
    while newval<limit+.5:
        newval=eval('2*'+str(e)+'**(num*rate)')
        valueatpoint.append(newval)
        num+=1
    return valueatpoint


#functions to create our resources
def load_image(name, colorkey=None):
    fullname = os.path.join('data', name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error, message:
        print 'Cannot load image:', fullname
        raise SystemExit, message
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()

def load_sound(name):
    class NoneSound:
        def play(self): pass
    if not pygame.mixer or not pygame.mixer.get_init():
        return NoneSound()
    fullname = os.path.join('data', name)
    try:
        sound = pygame.mixer.Sound(fullname)
    except pygame.error, message:
        print 'Cannot load sound:', fullname
        raise SystemExit, message
    return sound

def engine():
    pass

class Hydra(pygame.sprite.Sprite):
    """creates a Hydra on screen"""
    def __init__(self,parentx,parenty):
        pygame.sprite.Sprite.__init__(self) #call Sprite initializer
        randint=random.randint(1,100)
        if randint%2==1:
            self.image, self.rect = load_image('hydraA.bmp', -1)
        else:
            self.image, self.rect = load_image('hydraB.bmp', -1)
        self.rect.topleft=parentx,parenty
        self.xvel=1
        self.yvel=1
        self.xdir=1
        self.ydir=1

    def update(self):
        if self.rect.left<1:
            self.xdir=1
            self.xvel=4
        elif self.rect.top<1:
            self.ydir=1
            self.yvel=4
        elif self.rect.right>screen.get_size()[0]:
            self.xdir=-1
            self.xvel=-4
        elif self.rect.bottom>screen.get_size()[1]:
            self.ydir=-1
            self.yvel=-4
        randint=random.randint(1,120)
        if randint%5==4:
            newpos=self.rect.move((self.xvel,self.yvel))
        elif randint%5==3:
            xvel=1*self.xdir
            yvel=1*self.ydir
            newpos=self.rect.move((self.xvel,self.yvel))
        elif randint%5==2:
            xvel=1*self.xdir
            yvel=1*self.ydir
            newpos=self.rect.move((self.xvel,self.yvel))
        elif randint%5==1:
            xvel=-1
            yvel=0
            newpos=self.rect.move((self.xvel,self.yvel))
        elif randint%5==0:
            xvel=0
            yvel=-1
            newpos=self.rect.move((self.xvel,self.yvel))
        else:
            newpos=self.rect.move((0,0))
        self.rect=newpos

#Initialize Everything
pygame.init()
screen = pygame.display.set_mode((1200, 700))
pygame.display.set_caption('Hydra Attack')
pygame.mouse.set_visible(0)
hydraA=Hydra(random.randint(1,100),random.randint(1,100))
hydraB=Hydra(random.randint(101,200),random.randint(101,200))
#Create The Backgound
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
safebackground=background.copy()
#Display The Background
screen.blit(background, (0, 0))
pygame.display.flip()
#Prepare Game Objects
clock = pygame.time.Clock()
hydras=[hydraA,hydraB]
allsprites = pygame.sprite.RenderPlain((hydraA,hydraB))

def begin():
    curamount=2
    newamount=2
    turn = 0
    rounds=0
    while 1:
        #use the clock
        clock.tick(days)
        turn+=1
        if turn%5==0:
            rounds+=1
            if rounds>len(amount)-1:
                print rounds
                final = "It took the Hydra "+str(rounds)+" days to get to "+str(limit)+" from 2"
                text = font.render(final, 1, (10, 10, 10))
                textpos = text.get_rect(centerx=background.get_width()/2)
                background.blit(text, textpos)
                screen.blit(background, (0, 0))
                pygame.display.flip()
                pygame.time.delay(2500)
                pygame.quit()
                return
            newamount=int(amount[rounds])
            if newamount>curamount:
                hydras.append(Hydra(random.randint(2,screen.get_size()[0]),random.randint(2,screen.get_size()[1])))
                hydras[len(hydras)-1].add(allsprites)
                curamount=newamount
               
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                pygame.quit()
                return
        allsprites.update()

        #Draw Everything
        screen.blit(background, (0, 0))
        allsprites.draw(screen)
        pygame.display.flip()



def prep():
    font = pygame.font.Font(None, 40)
    rate='0'
    while 1:
        clock.tick(15)
        for event in pygame.event.get():
            if event.type == QUIT:
                return rate
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    return rate
                elif event.key==K_KP0:
                    rate+='0'
                elif event.key==K_KP1:
                    rate+='1'
                elif event.key==K_KP2:
                    rate+='2'
                elif event.key==K_KP3:
                    rate+='3'
                elif event.key==K_KP4:
                    rate+='4'
                elif event.key==K_KP5:
                    rate+='5'
                elif event.key==K_KP6:
                    rate+='6'
                elif event.key==K_KP7:
                    rate+='7'
                elif event.key==K_KP8:
                    rate+='8'
                elif event.key==K_KP9:
                    rate+='9'
                elif event.key==K_KP_PERIOD:
                    rate+='.'
                elif event.key==K_KP_ENTER:
                    return rate
        text = font.render("Please type in on the numpad the apropriate speed and then press enter", 1, (10, 10, 10))
        textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
        background.blit(text, textpos)
        screen.blit(background, (0, 0))
        pygame.display.flip()

def preps():
    font = pygame.font.Font(None, 40)
    rate='0'
    while 1:
        clock.tick(15)
        for event in pygame.event.get():
            if event.type == QUIT:
                return rate
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    return rate
                elif event.key==K_KP0:
                    rate+='0'
                elif event.key==K_KP1:
                    rate+='1'
                elif event.key==K_KP2:
                    rate+='2'
                elif event.key==K_KP3:
                    rate+='3'
                elif event.key==K_KP4:
                    rate+='4'
                elif event.key==K_KP5:
                    rate+='5'
                elif event.key==K_KP6:
                    rate+='6'
                elif event.key==K_KP7:
                    rate+='7'
                elif event.key==K_KP8:
                    rate+='8'
                elif event.key==K_KP9:
                    rate+='9'
                elif event.key==K_KP_PERIOD:
                    rate+='.'
                elif event.key==K_KP_ENTER:
                    return rate
        text = font.render("Please type on the numpad the apropriate days a second and press enter", 1, (10, 10, 10))
        textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
        background.blit(text, textpos)
        screen.blit(background, (0, 0))
        pygame.display.flip()

def preeps():
    font = pygame.font.Font(None, 40)
    rate='0'
    while 1:
        clock.tick(15)
        for event in pygame.event.get():
            if event.type == QUIT:
                return rate
            elif event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    return rate
                elif event.key==K_KP0:
                    rate+='0'
                elif event.key==K_KP1:
                    rate+='1'
                elif event.key==K_KP2:
                    rate+='2'
                elif event.key==K_KP3:
                    rate+='3'
                elif event.key==K_KP4:
                    rate+='4'
                elif event.key==K_KP5:
                    rate+='5'
                elif event.key==K_KP6:
                    rate+='6'
                elif event.key==K_KP7:
                    rate+='7'
                elif event.key==K_KP8:
                    rate+='8'
                elif event.key==K_KP9:
                    rate+='9'
                elif event.key==K_KP_PERIOD:
                    rate+='.'
                elif event.key==K_KP_ENTER:
                    return rate
        text = font.render("Please type on the numpad the number of hydras to go to and press enter", 1, (10, 10, 10))
        textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
        background.blit(text, textpos)
        screen.blit(background, (0, 0))
        pygame.display.flip()

font = pygame.font.Font(None, 24)
doubling=float(prep())
background.blit(safebackground,(0, 0))
while doubling<minimum or doubling>maximum:
    text = font.render("Please type in the number between "+str(minimum)+' and '+str(maximum)+'.', 1, (10, 10, 10))
    textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
    background.blit(text, textpos)
    screen.blit(background, (0, 0))
    pygame.display.flip()
    pygame.time.delay(1500)
    background.blit(safebackground,(0, 0))
    doubling=float(prep())
background.blit(safebackground,(0, 0))
days=int(preps())
background.blit(safebackground,(0, 0))
while days<1 or days>15:
    text = font.render("Please type in the number between 1 and 15.", 1, (10, 10, 10))
    textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
    background.blit(text, textpos)
    screen.blit(background, (0, 0))
    pygame.display.flip()
    pygame.time.delay(1500)
    background.blit(safebackground,(0, 0))
    days=int(preps())
background.blit(safebackground,(0, 0))
limit=int(preeps())
background.blit(safebackground,(0, 0))
while limit<5 or limit>250:
    text = font.render("Please type in the number between 5 and 250.", 1, (10, 10, 10))
    textpos = text.get_rect(centerx=background.get_width()/2,centery=background.get_height()/2)
    background.blit(text, textpos)
    screen.blit(background, (0, 0))
    pygame.display.flip()
    pygame.time.delay(1500)
    background.blit(safebackground,(0, 0))
    limit=int(preeps())
amount=calc_amount(doubling)
days=days*4
background.fill((0,0,255))
begin()

Splitting imports in several lines is the way to go according to the Python coding standards written by the creator of Python.

Nevertheless, the code is looking very good (spaces, commented and stuff).

I'd also recommend a main function like this:

Code: [Select]
if __name__ == "__main__":
    #Whatever should be ran in the beginning of the program

But I'm not sure of how that works in pygame.

1629
Gaming Discussion / Re: Omnimaga Haxball
« on: May 09, 2011, 07:41:24 am »
I see this game is picking up some interest around here. Too bad I can't show Runer112 who's boss cos we can't have even games :(

1630
Casio PRIZM / Re: Prizm Snake
« on: May 09, 2011, 07:39:41 am »
So Ashbad, how's this going?

1631
TI Z80 / Re: Voyager X
« on: May 09, 2011, 07:39:19 am »
Good luck collechess! How's this going?

1632
TI Z80 / Re: Triathlon
« on: May 09, 2011, 07:38:39 am »
May I know what language you're using? This reminds me of Simul, good job so far :D

1633
TI Z80 / Re: The Chosen
« on: May 09, 2011, 07:37:34 am »
The battle engine is looking really good and so are the conversations (dialogs). Great, great! Is it pure basic?

1634
TI Z80 / Re: Final Fantasy - Quest for Rana
« on: May 09, 2011, 07:35:37 am »
I finally read the story the other day and it looked intriguing, how is the coding going on? Any progress?

1635
TI Z80 / Re: Eitrix for TI-84 Plus
« on: May 09, 2011, 07:35:04 am »
SAD DAY!  :'(

The compiled Eitrix just hit the 8811 byte limit! I was adding a score system to the game, and the game immediately crashed when code broke into the fourth page. Now all progress will be stopped until I hunker down and optimize the thing to death. :banghead:

(And before anyone suggests I compile as an APP, that is not an option to me, because not only would that lock me out of any possibility of CALCnet, but also, my calc likes to turn off randomly, and if it turns off while the APP is writing, I lose everything).

That's really sad, also because it can't be compiled as an App. :( Good Luck with optimizing, perhaps you can ask help in the forums with that?

Pages: 1 ... 107 108 [109] 110 111 ... 424