Jump to content

  • Log In with Google      Sign In   
  • Create Account


Safixk

Member Since 09 Sep 2012
Offline Last Active Nov 07 2012 10:40 PM
-----

Topics I've Started

PyGame - Multi-Directional Movement and Sprite Transformations

07 November 2012 - 11:11 AM

Hey There! I'm making a game using Python(v2.6.6), and the PyGame library.
It's a RPG game, and I've barely started... But questions have already come up.
I want to make a way in which the character will not only go in all directions...
But I also want it so the sprite changes according to the direction I'm going.
I've managed to create a loop that animates the walking movement - For the Up and Down directions
but the image doesn't turn around according to the direction... Also the way I made to loop the images
was a I thing that came up to me - I'm not sure if it's correct, nor if its the best way to do so.

Here's my code, and thanks for any and all help:
[source lang="python"]import pygame, sys, globfrom pygame import *pygame.init()size = width, height = 600,400clock = pygame.time.Clock()black = 0,0,0screen = pygame.display.set_mode(size)class player: def __init__(self): self.x = 300 self.y = 200 self.ani_speed_init=10 self.ani_speed=self.ani_speed_init self.ani = glob.glob("chardown*.png") self.ani.sort() self.ani_pos=0 self.ani_max = len(self.ani) -1 self.img = pygame.image.load(self.ani[0]) self.update(0) def update(self, pos): if pos != 0: self.ani_speed-=1 self.y+=pos if self.ani_speed == 0: self.img = pygame.image.load(self.ani[self.ani_pos]) self.ani_speed = self.ani_speed_init if self.ani_pos == self.ani_max: self.ani_pos = 0 else: self.ani_pos+=1 screen.blit(self.img,(self.x,self.y))player1 = player()pos = 0while 1: clock.tick(60) screen.fill(black) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == KEYDOWN and event.key == K_DOWN: pos = 1 elif event.type == KEYUP and event.key == K_DOWN: pos = 0 elif event.type == KEYDOWN and event.key == K_UP: pos = -1 elif event.type == KEYUP and event.key == K_UP: pos = 0 player1.update(pos) pygame.display.update()[/source]

Anyone up for Tutoring?

04 November 2012 - 07:44 PM

Hello There!
Believe it or not I'm 13(as of two weeks ago) and I have had experience with your typical Web Development knowledge(HTML, CSS, PHP, MySQL, etc..)
And right now I'm looking for a bigger challenge: Game Development - Thus why I've come to the wonderful GameDev community to see if anyone would be willing to share their knowledge
I've tried everything from Books to Online Courses - Nothing worked because they didn't achieve what I was looking for, and some of them where awfully paced and I couldn't learn anything that they taught (leading me to drop out) - But mainly because when I had a question outside of the FAQ's, well, there was no one for me to use as a recourse.
I want to start developing in C++ because it seems like the perfect fit for making games, it's lightweight, fast, and not too hardware intensive.
But if you think I should start learning something prior to it, another flavor, or language even, just tell me where I can learn it.
I've got email, skype, and can acquire anything else.
So if you're up to it, just reply to the thread with some contact info, and maybe a project that you've made before, and I'll PM you according to my need.
Thanks for any and all help.

EDIT: Nevermind - I just found something that might just cut it for me

PARTNERS