TreeSaaaaap

Members
  • Content count

    12
  • Joined

  • Last visited

Community Reputation

139 Neutral

About TreeSaaaaap

  • Rank
    Member
  1. Hi guys,   I've been working in Java for a little while now (after learning some Python and C++) and I'm feeling more comfortable with Java syntax more than the other languages so far.   I'm looking for a resource that will help me to better understand (in-depth) how to actually render terrain and models, and at some point help me understand the process of doing this with a client/server connection.  I find some decent articles and reading out there, but these things still confuse me.   I realize that it's a bit advanced, but it is something I could work towards as a hobby.  I'd love to create a multiplayer game similar to Ultima Online.  But if I could figure out how to render a map like that (isometric and terrain/tiles?) and have it work as a multiplayer game I'd be extremely happy.  Did UO use a heightmap, large bitmap, or just render a huge map of small tiles right next to each other?   Also, would you guys suggest trying the jmonkeyengine?   Lastly, this might be a dumb question but how is gear rendered both on a player, and in a paperdoll with the ability to die a section of armor?  Graphics programming seems extremely difficult.   What would you guys suggest as a decent resource for transitioning from basic Java to understanding some graphics and server/client programming?   Thanks!
  2. Vectors Newb

    import pygame, sys class Player(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("char.png").convert() self.rect = self.image.get_rect() def draw(self, screen): self.image = pygame.transform.scale(self.image, (75, 75)) screen.blit(self.image, (self.rect.x, self.rect.y)) def update(self, mlocX, mlocY, n_steps): self.rect.x += (mlocX - self.rect.x) / n_steps self.rect.y += (mlocY - self.rect.y) / n_steps import pygame, sys import oPC pygame.init() WINDOWSIZE = (1000, 800) BLACK = (0, 0, 0) screen = pygame.display.set_mode((WINDOWSIZE)) pygame.display.set_caption("TTB") screen.fill(BLACK) terrain = pygame.image.load("terrain.jpg").convert() terrainRect = terrain.get_rect() terrain = pygame.transform.scale(terrain, ((WINDOWSIZE))) screen.blit(terrain, terrainRect) oPC = oPC.Player() oPC.draw(screen) pygame.display.flip() running = True n_steps = 80 while running == True: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.MOUSEBUTTONDOWN: mlocX, mlocY = pygame.mouse.get_pos() while mlocX != oPC.rect.x and mlocY != oPC.rect.y: oPC.update(mlocX, mlocY, n_steps) if n_steps > 1: screen.fill(BLACK) screen.blit(terrain, terrainRect) n_steps -= 1 oPC.draw(screen) pygame.display.flip() n_steps = 80 pygame.quit() #sys.exit() I understand the point of not wanting to have another loop running inside of there, but I'm not quite sure how to iterate it another way so it gradually moves towards the mouses target location (without having to click or roll the mouse wheel constantly).  I was thinking, would it be more efficient to control the movement by time somehow as opposed to using steps?  It works this way now, but the image makes it to different distances at the same amount of time, which isn't exactly great for character movement.
  3. Vectors Newb

    Ok, I see what you're saying about not wanting to throw another loop in there, but I'm not sure how to iterate it another way so it moves on it's own and so that I don't need to keep clicking for each movement.  Right now, it only moves a step for each mouse event.
  4. Vectors Newb

    So, I'm getting this closer to working it seems.  I'm getting it to run through the while loop, and the object actually moves to the location I've clicked.  However, when it reaches that point, the program freezes and I really have no clue why.  At some point, the conditions should be met (at the same time) and the while loop should end.  Is this crashing because x and y are not being met at the same moment?  Hmm... import pygame, sys class Player(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("char.png").convert() self.rect = self.image.get_rect() def draw(self, screen): self.image = pygame.transform.scale(self.image, (75, 75)) screen.blit(self.image, (self.rect.x, self.rect.y)) def update(self, mlocX, mlocY): self.rect.x += (mlocX - self.rect.x) / 110 self.rect.y += (mlocY - self.rect.y) / 110 import pygame, sys import oPC pygame.init() WINDOWSIZE = (1000, 800) BLACK = (0, 0, 0) screen = pygame.display.set_mode((WINDOWSIZE)) pygame.display.set_caption("TTB") screen.fill(BLACK) terrain = pygame.image.load("terrain.jpg").convert() terrainRect = terrain.get_rect() terrain = pygame.transform.scale(terrain, ((WINDOWSIZE))) screen.blit(terrain, terrainRect) oPC = oPC.Player() oPC.draw(screen) pygame.display.flip() running = True while running == True: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.MOUSEBUTTONDOWN: mlocX, mlocY = pygame.mouse.get_pos() while oPC.rect.x != mlocX and oPC.rect.y != mlocY: screen.fill(BLACK) screen.blit(terrain, terrainRect) oPC.update(mlocX, mlocY) oPC.draw(screen) pygame.display.flip() pygame.quit() #sys.exit()
  5. Vectors Newb

    Ahhh..yes...>.<  An hour spent skipping over that....  I'm thinking it's quitting time for the day.  Thanks so much for the help guys!
  6. Vectors Newb

    Having some serious trouble, just with line 2, and I have no clue why haha... import pygame, sys class Player(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("char.png").convert() self.rect = self.image.get_rect() def update(self, mlocX, mlocY): self.rect.x += (mlocX - self.rect.x) / 10 self.rect.y += (mlocY - self.rect.y) / 10 def draw(self, screen) screen.blit(self.image, (self.rect.x, self.rect.y)) import pygame, sys import oPC pygame.init() WINDOWSIZE = (1000, 800) BLACK = (0, 0, 0) screen = pygame.display.set_mode((WINDOWSIZE)) pygame.display.set_caption("TTB") screen.fill(BLACK) terrain = pygame.image.load("terrain.jpg").convert() terrainRect = terrain.get_rect() terrain = pygame.transform.scale(terrain, ((WINDOWSIZE))) screen.blit(terrain, terrainRect) pygame.display.flip() oPC = Player() running = True while running == True: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.MOUSEBUTTONDOWN: mlocX, mlocY = pygame.mouse.get_pos() screen.fill(BLACK) screen.blit(terrain, terrainRect) oPC.update(mlocX, mlocY) oPC.draw(screen) pygame.display.flip() pygame.quit() #sys.exit() Traceback (most recent call last): File "C:/Users/Daniel/Downloads/PyServ/PyServ/TheGame/main.py", line 2, in <module> import oPC File "C:/Users/Daniel/Downloads/PyServ/PyServ/TheGame\oPC.py", line 15 def draw(self, screen) ^ SyntaxError: invalid syntax I'm not sure what is going wrong...  Trying to weed out the errors.
  7. Vectors Newb

    Awesome!  Thanks for the clarity.  I got to the point of computing it, just not factoring in the division of steps.   By arriving smoothly, I was worried that the x and y wouldn't be updated at the same time and cause a rigid movement.
  8. Vectors Newb

    Hi,    I'm trying to learn Python and program an RPG (perhaps transitioning into a multiplayer RPG someday - once I have a better understanding of what I'm doing!)  I've enjoyed tinkering around in C++ over the years, but I still consider myself a big time newb.  I learned most of the Python syntax already however, and I'm enjoying it thus far.  Also, I've picked up Pygame to help me write this game.   My question is about vectors.  I'm not exactly a math genius (and some of you may say to just drop programming now), but I really want to learn...   Basically, I want to move the player object to the location of a mouse click (similar to that in Diablo, UO, etc) whatever angle it might be.  Very simply, I want to move the player object from the objects current coordinates to the mouse click position coordinates.  I've scratched my head for many hours already trying to figure out exactly how to do it.     I can't understand if it's the vector itself I need, or the magnitude, direction, velocity, angle etc.  I just want to move (2,0) to (33,33) arriving smoothly at each x and y coordinate, etc.  Perhaps, I'm doing this all the wrong way.   Anyone know of a better resource that might help me understand this a little better/easier?     Thanks!    
  9. Python (pygame) Slow Blit?

    Ahh.. I see. Thanks again for the info!
  10. Python (pygame) Slow Blit?

    That is good news!  For clarity purposes though, do we constantly have to blit images (including the terrain) every time something changes?  If that's the case, won't it eventually slow down with thousands of image objects moving (and terrain reloading)?  Or...say for instance, we have a multiplayer game where we're having to blit all of these images for everyone....Wouldn't that really slow it down?     I realize I have much to learn if I ever choose to go the multiplayer route, but I suppose I'm asking out of curiousity...
  11. Python (pygame) Slow Blit?

    Wow.  That was exactly it.  I'm not even sure what I was thinking now... Thank you for pointing that out though.  Apologies.
  12. Python (pygame) Slow Blit?

    Hello Everyone,    This is my first post here, but I plan on spending a lot of time here trying to learn (and help others).   I've dabbled in c++ off and on for the last few years, but I found myself struggling to find a project that wasn't too challenging (or too easy) and I stepped away for a bit.   Recently, I started teaching myself a bit about Python.  Apparently, it's a simpler language (that can do a lot) and I figure I'll give it a shot, maybe I can accomplish something.  So I set out the other day and now I'm here...   I've attempted to render a background image (or terrain) with another image on top that can move to the location of a mouse click.  I'm having trouble understanding why the image won't move precisely when I click, every time. For instance, if I click in quick succession, the image may only change locations once every second or more.   I have a feeling like it has something to do with constantly having to redraw the images, perhaps slowing it down?  If that's the case, I wouldn't understand why because I thought that the game loop would iterate many times a second.... Or maybe my loop isn't working right?  Can I just "move" an image instead of the constant "blit-ing"?  If not, then this kind of concerns me with what I plan on doing in the future.  (When I click a point on the terrain, I want to move, or walk, the image to that point).   Obviously, this is a very simple task, especially for some of you, but I can't really tell if it's a problem with the way I'm coding it or if it's really how slow python/pygame is?   Here is the code: import sys, pygame pygame.init() SCREEN_WIDTH = 1200 SCREEN_HEIGHT = 800 BLACK = (0, 0, 0) screen = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT]) pygame.display.set_caption("TTB") screen.fill(BLACK) #set cursor here somewhere terrain = pygame.image.load("terrain.jpg") terrainRect = terrain.get_rect() terrain = pygame.transform.scale(terrain, (SCREEN_WIDTH, SCREEN_HEIGHT)) screen.blit(terrain, terrainRect) oPC = pygame.image.load("amishdude.png") oPC = pygame.transform.scale(oPC, (75, 75)) oPCrect = oPC.get_rect() screen.blit(oPC, oPCrect) pygame.display.flip() running = True #initialize the main game loop while running == True: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False #break loop and close for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: mouseRect = pygame.mouse.get_pos() screen.fill(BLACK) screen.blit(terrain, terrainRect) screen.blit(oPC, mouseRect) pygame.display.update() pygame.quit() #sys.exit()