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 - ruler501

Pages: 1 ... 171 172 [173] 174 175 ... 184
2581
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 08:01:45 pm »
I was going to make a jumping style where you jump up and avoid objects like fire, water, and possibly sand. I might develop farther on this design eventually for now that is it. The game will not be the same every time and will have a randomness to the events. The main part i want to emphasize in this game is the physics.

Why can't I have cellular automata use the same gravity?

2582
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 07:55:01 pm »
Yes if I can get it all working correctly I will implement all of those.

2583
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 07:49:19 pm »
I still don't quite get how to do cellular automata efficiently yet so I haven't put it in. I'm slowly adding in game parts and physics. I need collision detection and an efficient way of doing cellular automata. I'll have gravity set up soon. It might be a slightly different way from what you had on the physics lessons.

2584
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 07:30:29 pm »
Here is my code so far All I have it do is move the sprite around with keyboard inputs. I know it is a little slow right now but that makes it easier for me. Next on my to do list is add gravity. I would appreciate any ideas for optimization or improvements.
Code: [Select]
#import modules
import pygame, math, random, os
from pygame.locals import *

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

#define any needed global variables here

    
#Create a function to load images for sprites.
def load_image(name, colorkey=None):
    fullname = os.path.join('data', name)
    try:
        image = pygame.image.load(fullname)
    #If an error exit
    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()

#create a function to load sound
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)
    #if an error exit
    except pygame.error, message:
        print 'Cannot load sound:', fullname
        raise SystemExit, message
    return sound

#classes for our game objects
class Player(pygame.sprite.Sprite):
    #moves a clenched fist on the screen, following the mouse
    def __init__(self):
        pygame.sprite.Sprite.__init__(self) #call Sprite initializer
        self.image, self.rect = load_image('sprite.bmp', -1)
        self.direction=0

    def update(self):
        #move the player based on direction chosen
        if self.direction == 0:
            return
        elif self.direction == 1:
            newpos = self.rect.move((0, -2))
            self.rect = newpos
        elif self.direction == 2:
            newpos = self.rect.move((0, 2))
            self.rect = newpos
        elif self.direction == 3:
            newpos = self.rect.move((-2, 0))
            self.rect = newpos
        elif self.direction == 4:
            newpos = self.rect.move((2, 0))
            self.rect = newpos

    def up(self):
        self.direction=1

    def down(self):
        self.direction=2

    def left(self):
        self.direction=3

    def right(self):
        self.direction=4

    def still(self):
        self.direction=0

#function to load the game engine
def game_engine():
    #nothing done here yet
    return

#function for playing the game
def play_game():
    #load the game engine
    game_engine()
    #start the game
    #Initialize Everything
    pygame.init()
    screen = pygame.display.set_mode((975, 325))
    pygame.display.set_caption('Physics!')
    pygame.mouse.set_visible(1)
    turn = 0
    win = False
    lose = False
    achievements = 0

    #Create The Backgound
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((250, 250, 250))

    #Display The Background
    screen.blit(background, (0, 0))
    pygame.display.flip()

    #Prepare Game Objects
    clock = pygame.time.Clock()
    player = Player()
    allsprites = pygame.sprite.RenderPlain((player))
    #Main Loop
    while 1:
        clock.tick(25)

    #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT:
                return
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                return
            if event.type == KEYDOWN and event.key == K_UP:
                player.up()
            elif event.type == KEYDOWN and event.key == K_DOWN:
                player.down()
            elif event.type == KEYDOWN and event.key == K_LEFT:
                player.left()
            elif event.type == KEYDOWN and event.key == K_RIGHT:
                player.right()
            else:
                player.still()
                
                

        allsprites.update()

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

def main():
    #define needed local variables here
    
    #start game
    play_game()
    
if __name__ == '__main__':
    main()

EDIT: @alberthrocks that is why i intend to at least at 1 point in the game have nearly the whole screen consumed by a mixture of fire and water and That would considerably slow down the game to have to loop through all of them.

2585
Other / Re: Robotics Competiton!!!
« on: February 01, 2011, 06:30:08 pm »
OK that is not one I know sorry that I can not be of help.

2586
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 06:28:25 pm »
I am intermediate At python i mainly have used it for pretty simple games. This is my first attempt at a more difficult game. I almost have the basics of the game working right now I need a sprite though and I'm trying to decide what to use.
and it wasn't that I didn't know how to do it it was that i wanted to try and find an optimized way of doing it without looping through every single pixel.

2587
Other / Re: Robotics Competiton!!!
« on: February 01, 2011, 06:17:42 pm »
what are you guys programming in and what exactly are you programming? I might be able to help

2588
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 04:54:18 pm »
Could i have an example of some python code for that please. I'm trying to figure out a way to optimize this it would be slow i think if i have to go through most pixels in a nearly if not full screen game.

The only reason i might not do full screen is because i want this to be a very fast game that won't glitch up. i think it would be easier if i had a slightly smaller screen size.

2589
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 04:06:11 pm »
My only calculator is a Nspire so i can't do much on calc testing.
I have not done much with my code yet right now I only have a background. As soon as I start doing much with it I will post my code.

2590
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 03:51:14 pm »
I wanted to know how to do the cellular automata. I also need to be able to do good collision detection and gravity.
First off - have you made the concept on your calculator, and does it work?
Second, are you well versed with Python and Pygame?
Third, can we see some sample code? :)

I don't get the first one This is a comp program
I'm well versed with python and have done all right with pygame
I'm still making up the code, but if you want to see some code I'll post it later.

@Builderboy I want to know how to optimize that code and some of the concept

2591
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 03:42:16 pm »
I wanted to know how to do the cellular automata. I also need to be able to do good collision detection and gravity.

2592
Computer Projects and Ideas / Re: My physics game
« on: February 01, 2011, 03:09:44 pm »
I'm using pygame for graphics. I don't really know any of the other ones

EDIT: if it matters I'm using python 2.6.2

2593
Computer Projects and Ideas / My physics game
« on: February 01, 2011, 02:10:23 pm »
I am currently making a physics game using some of the techniques in this thread http://ourl.ca/4279 I am writing it in python because it is the only language I know well enough to do something like this in. I have a few questions about some things so any help would be appreciated. right now I just finished my skeleton code and am starting on the game engine. I am currently using pygame for graphics, I also have python 2.6.2

My first Question is how could I code Cellular Automata in python for a large/full screen?

2594
TI-Nspire / Re: TI-Nspire Video Player
« on: February 01, 2011, 12:04:40 pm »
15 MB for 1:38 of video on a calc isn't that bad

2595
TI-Nspire / Re: TI-Nspire Video Player
« on: February 01, 2011, 11:56:36 am »
This is amazing. How large are these files?

Pages: 1 ... 171 172 [173] 174 175 ... 184