Tema: laberinto
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2009, 11:36
xulubkisin
 
Fecha de Ingreso: junio-2009
Mensajes: 5
Antigüedad: 14 años, 10 meses
Puntos: 0
laberinto

bueno, me acerco a uds para ver si me colaboran en esto que quiero hacer hace rato, pero por falta de sabiduria no he podido terminar, se trata de un laberinto casi imposible de solucionar, pero la cuestin es hacer una colision para una imagen completa y ademas tan grande en formato "png".

la otra parte del juego que es el movimiento de la pelota atravez del laberinto y la creacion de un afecto camara, eso lo saque de un ejemplo de esta pagina ://brunoprog64.blogsome.com/2008/01/24/efecto-de-camera-con-pygame/ el de esta pagina tiene unos cuantos errores que arregle a duras penas, quemando pestaña toda una semana, por que la verdad no encontre nada mas en ningun sitio, y no se mucho de programar, por eseo me fue tan dificil, pero ya esta. bueno, aqui esta el codigo

Código:
Código python:
Ver original
  1. # #### efecto camara laberinto #### #
  2.  
  3. # -*- coding: iso-8859-1 -*-
  4.  
  5. import wx
  6.  
  7. provider = wx.SimpleHelpProvider()
  8. wx.HelpProvider_Set(provider)
  9.  
  10. import MyFrame
  11.  
  12.  
  13. class App(wx.App):
  14.     def OnInit(self):
  15.         wx.InitAllImageHandlers()
  16.         self.main = MyFrame.MyFrame(None,-1,'')
  17.         self.main.Show()
  18.         self.SetTopWindow(self.main)
  19.         return 1
  20.  
  21. def main():
  22.     application = App(0)
  23.     application.MainLoop()
  24.  
  25. if __name__ == '__main__':
  26.     main()
  27.  
  28.  
  29.  
  30.  
  31. class VwXtaskBar(wx.TaskBarIcon):
  32.     def __init__(self,win):
  33.         self.win=win
  34.         wx.TaskBarIcon.__init__(self)
  35.         self.Bind(wx.EVT_TASKBAR_MOVE,self.VwXAllEvents)
  36.         self.Bind(wx.EVT_TASKBAR_LEFT_DOWN,self.VwXAllEvents)
  37.         self.Bind(wx.EVT_TASKBAR_LEFT_UP,self.VwXAllEvents)
  38.         self.Bind(wx.EVT_TASKBAR_RIGHT_DOWN,self.VwXAllEvents)
  39.         self.Bind(wx.EVT_TASKBAR_RIGHT_UP,self.VwXAllEvents)
  40.         self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK,self.VwXAllEvents)
  41.         self.Bind(wx.EVT_TASKBAR_RIGHT_DCLICK,self.VwXAllEvents)
  42.         self.Bind(wx.EVT_MENU,self.OnMenu,id=-1)
  43.        
  44.     def VwXAllEvents(self,event):
  45.         self.win.GetEventHandler().ProcessEvent(event)
  46.         if(event.GetEventType()==wx.wxEVT_TASKBAR_RIGHT_DOWN):
  47.             event.Skip(True)
  48.  
  49.     def CreatePopupMenu(self):
  50.         return self.win.VwXGetTaskBarMenu()
  51.  
  52.     def OnMenu(self,event):
  53.         self.win.GetEventHandler().ProcessEvent(event)
  54.  
  55.  
  56.  
  57. import pygame
  58. from pygame.locals import *
  59.  
  60. pygame.init()
  61.  
  62.  
  63.  
  64. campo = pygame.image.load('imag/campo.jpg')
  65. bola = pygame.image.load('imag/icono3.png')
  66. fondo = pygame.image.load("imag/laberinto.png")
  67. bol = bola.get_rect()
  68.  
  69.  
  70.  
  71.  
  72. bol.left = 35
  73. bol.top = 45
  74.  
  75. bola_tl = bol.left
  76. bola_tt = bol.top
  77. ayu = 5
  78.  
  79. clock = pygame.time.Clock()
  80.  
  81. screen = pygame.display.set_mode((320,240))
  82.  
  83. n = 0
  84. campo_x = 0
  85. campo_y = 0
  86.  
  87.  
  88.  
  89.  
  90.  
  91. while n <> 1:
  92.     screen.blit(campo, (campo_x,campo_y))
  93.     screen.blit(bola, (bola_tl, bola_tt))
  94.     screen.blit(fondo, (campo_x, campo_y))
  95.     pygame.display.flip()
  96.    
  97.     clock.tick(50)
  98.    
  99.     pygame.event.pump()
  100.     tecla_pres = pygame.key.get_pressed()
  101.    
  102.  
  103.    
  104.     if tecla_pres[K_LEFT]:
  105.         bol.left = bol.left - 5
  106.         bola_tl = bola_tl - 5
  107.        
  108.         if bola_tl <10> 10:
  109.                
  110.                 bola_tl = 10
  111.                 campo_x = campo_x + ayu
  112.             else:
  113.                 bola_tl = 10
  114.                 bol.left = 10
  115.        
  116.     if tecla_pres[K_RIGHT]:
  117.         bol.left = bol.left + 5
  118.         bola_tl = bola_tl + 5
  119.        
  120.        
  121.         if bola_tl > 290:
  122.             if bol.left  <4970> 20:
  123.                    
  124.                    bola_tl = 290
  125.                    campo_x = campo_x - ayu
  126.             else:      
  127.               bola_tl = 290
  128.               bol.left = 4970
  129.              
  130.                
  131.              
  132.                
  133.     if tecla_pres[K_UP]:
  134.         bol.top = bol.top - 5
  135.         bola_tt = bola_tt - 5
  136.        
  137.         if bola_tt <10> 10:
  138.                
  139.                 bola_tt = 10
  140.                 campo_y = campo_y + ayu
  141.             else:
  142.                 bola_tt = 10
  143.                 bol.top = 10
  144.          
  145.        
  146.     if tecla_pres[K_DOWN]:
  147.         bol.top = bol.top + 5
  148.         bola_tt = bola_tt + 5
  149.        
  150.        
  151.         if bola_tt > 210:
  152.             if bol.top  <4970> 210:
  153.                    
  154.                    bola_tt = 210
  155.                    campo_y = campo_y - ayu
  156.             else:      
  157.                 bola_tt = 210
  158.                 bol.top = 4970
  159.              
  160.              
  161.              
  162.              
  163.              
  164.     for event in pygame.event.get():
  165.         if event.type == QUIT:
  166.             n = 1
  167.         if event.type == KEYDOWN:
  168.             if event.key == K_ESCAPE:
  169.                 n = 1
  170.             if event.key == K_p:
  171.                 print "Valor Campo_x: ", campo_x
  172.                 print "Valores de bola - Camara:"
  173.                 print "Left: ", bol.left
  174.                 print "Top: ", bol.top
  175.                 print "Valores de bola - Pantalla:"
  176.                 print "Left: ", bola_tl
  177.                 print "Top: ", bola_tt

y pues aca esta un rar de el proyecto, por si quieren verlo funcionando y veran que es lo que quiero hacer, es un poquito pesado, pero por lo que las imagenes de el laberinto son tan grandes.
por algo es un laberinto casi imposible de solucionar.

://rapidshare.com/files/247044695/laberinto_paso_1.rar.html solo es cuestion de agregar el http al principio

Última edición por AlvaroG; 23/06/2009 a las 10:24