<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-434935525053944599</id><updated>2024-10-24T09:45:17.891+02:00</updated><category term="Material de teoría"/><category term="Diario del viajero"/><category term="Código fuente"/><category term="SDL"/><category term="Recursos"/><category term="diseño"/><category term="creación"/><category term="python"/><category term="Análisis de recursos"/><category term="Programación"/><category term="gráficos"/><category term="guión"/><category term="joystick"/><category term="programando juegos"/><category term="eventos"/><category term="Humor"/><category term="IA"/><category term="Noticias"/><category term="controlador"/><category term="coursera"/><category term="dispositivos"/><category term="hundir la flota"/><category term="inteligencia artificial"/><category term="librerias"/><category term="niveles"/><category term="oculus rift"/><category term="organización"/><category term="personaje"/><category term="ratón"/><category term="redes"/><category term="teclado"/><category term="ítem"/><category term="2D"/><category term="Spock"/><category term="adivina un numero"/><category term="aprendizaje"/><category term="asteroids"/><category term="bitmaps"/><category term="blackjack"/><category term="carpetas"/><category term="colisiones"/><category term="color key"/><category term="creative commons"/><category term="cronómetro"/><category term="curiosidades"/><category term="derechos de autor"/><category term="diccionario"/><category term="doppler"/><category term="enemigo"/><category term="feedback"/><category term="figuras básicas"/><category term="flags"/><category term="fotos"/><category term="gee"/><category term="guess a number"/><category term="imagenes"/><category term="indie"/><category term="jefe final"/><category term="lizard"/><category term="make"/><category term="makefile"/><category term="móvil"/><category term="obra"/><category term="online"/><category term="paper"/><category term="pong"/><category term="principios"/><category term="propiedad intelectual"/><category term="protagonista"/><category term="recordar"/><category term="rice"/><category term="ricerocks"/><category term="rock"/><category term="rocks"/><category term="scissors"/><category term="significación"/><category term="sinergia sin control"/><category term="sonido"/><category term="storyline"/><category term="trabajo"/><category term="trailer"/><category term="transparencia"/><category term="villano"/><category term="virtuix omni"/><title type='text'>Mundos del Videojuego</title><subtitle type='html'>Una aventura de frikis mochileros por los mundos del videojuego</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>91</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-6835874057742866402</id><published>2014-08-08T14:01:00.000+02:00</published><updated>2014-08-08T14:01:00.488+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="dispositivos"/><category scheme="http://www.blogger.com/atom/ns#" term="Noticias"/><category scheme="http://www.blogger.com/atom/ns#" term="oculus rift"/><category scheme="http://www.blogger.com/atom/ns#" term="virtuix omni"/><title type='text'>Virtuix Omni</title><content type='html'>¿Os acordáis de &lt;a href=&quot;http://mundosdelvideojuego.blogspot.com/2013/10/oculus-rift.html&quot;&gt;Oculus Rift&lt;/a&gt;? Que por cierto, &lt;a href=&quot;http://www.xataka.com/consolas-y-videojuegos/facebook-compra-oculus-por-2-000-millones-de-dolares&quot;&gt;pertenece a facebook ahora por su compra&lt;/a&gt;.
&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsRsyY0kt2BaVSkCaedqRFikuKev3DNzmLxjJ2N6_tz6ukhQIdGkRtrXApVeMoUy-Do23DMQINywRTWB4aqDTl0nvI02fjrYbCMEETtZRuRfwVFCQappLFd88tQtD5EyMW3gjMjMrD1Rq/s1600/Virtuix.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsRsyY0kt2BaVSkCaedqRFikuKev3DNzmLxjJ2N6_tz6ukhQIdGkRtrXApVeMoUy-Do23DMQINywRTWB4aqDTl0nvI02fjrYbCMEETtZRuRfwVFCQappLFd88tQtD5EyMW3gjMjMrD1Rq/s400/Virtuix.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
Pues aquí un complemento ideal, el Virtuix Omni. Hay otro similar por ahí cuyo nombre no me acuerdo. Son tecnologías que ya llevan rulando tiempo, a ver para cuando se convierte en una realidad más tangible.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;&lt;br&gt;
Os dejo el enlace a su web y un vídeo, y a dejar volar la imaginación como lo he hecho yo. Ojalá termine de desarrollarse estas tecnologías...&lt;br&gt;&lt;br&gt;
&lt;center&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/zZqbkdUBMUE&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;&lt;/center&gt;
&lt;br&gt;&lt;br&gt;
&lt;a href=&quot;http://www.virtuix.com/&quot;&gt;Virtuix Omni&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/6835874057742866402/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/virtuix-omni.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/6835874057742866402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/6835874057742866402'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/virtuix-omni.html' title='Virtuix Omni'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKsRsyY0kt2BaVSkCaedqRFikuKev3DNzmLxjJ2N6_tz6ukhQIdGkRtrXApVeMoUy-Do23DMQINywRTWB4aqDTl0nvI02fjrYbCMEETtZRuRfwVFCQappLFd88tQtD5EyMW3gjMjMrD1Rq/s72-c/Virtuix.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-7757170857101640186</id><published>2014-08-08T14:00:00.000+02:00</published><updated>2014-08-08T14:00:01.781+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 198</title><content type='html'>Y retomamos esto después de otra parada, en la que no he avanzado, e incluso retrocedido en el camino de entre los mundos del videojuego. Pero con la experiencia y el error se aprende, y coursera es buen sitio y se aprenden cosas aunque gasta un tiempo que debería haber usado para recorrer estos mundos. Es por ello, que dejaré coursera de lado.
&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMnd7b5dkX8titjUJWZ-mI5O09ROlX17nUBMvsA79zwddIRcTQYNwSA5G_kAV1YfSINRv0qMVBbJGEIk3_CFAn72SAeb1dT-yPl38cFUYERSz_ZAgM-yvZic01IpJI3v_ZJ3lSpMR41JGT/s1600/left4dead2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMnd7b5dkX8titjUJWZ-mI5O09ROlX17nUBMvsA79zwddIRcTQYNwSA5G_kAV1YfSINRv0qMVBbJGEIk3_CFAn72SAeb1dT-yPl38cFUYERSz_ZAgM-yvZic01IpJI3v_ZJ3lSpMR41JGT/s1600/left4dead2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
En este tiempo he estado programando proyectos, y mi velocidad y experiencia crece, me siento más capaz y veo cómo mi visión y análisis de los juegos evoluciona, entrando en un mundo que no conocía, el de jugar cooperativamente online en un juego de supervivencia y muchos tiros.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;&lt;br&gt;
Y me ha gustado mucho el sentimiento de ayuda entre todos, de forma desinteresada con un objetivo común y sin conocernos. Es un mundo mucho más rico del que pensaba. (y si, era Left 4 dead 2 el que probé).
&lt;br&gt;&lt;br&gt;
Del diccionario también nos llegan nuevas palabras:
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;NDA&lt;/b&gt;&lt;br/&gt;
Acrónimo del término inglés Non-Disclosure Agreement (Acuerdo de Confidencialidad).
&lt;br/&gt;&lt;br/&gt;
Contrato legal que firman los desarrolladores y/o los medios de prensa y que les impide hacer pública la información que las compañías consideran secreto profesional. Esto incluye tanto los propios proyectos de las desarrolladoras (un trabajador no puede hablar de un juego si la desarrolladora no ha hecho público su desarrollo o ciertas características del proyecto) como información confidencial fruto de relaciones entre diferencias entre compañías (documentos de desarrollo de las consolas, documentación y/o código de middleware, código accesible vía contrato de outsourcing donde la empresa contratada accede al código del juego de la empresa contratante, etc).
&lt;br/&gt;
(Industria, Prensa)
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Demake&lt;/b&gt;&lt;br/&gt;
Del inglés de-make (deshacer) como opuesto a re-make (rehacer).
&lt;br/&gt;&lt;br/&gt;
Adaptación de un videojuego moderno a una plataforma antigua.
&lt;br&gt;
No se realiza de manera comercial, sino que es una tendencia surgida entre la comunidad de jugadores retro, que los realizan de manera desinteresada como oposición a los remakes, que adaptan juegos antiguos a nuevas plataformas.
&lt;br&gt;
(Cultura gamer, Reediciones)
&lt;br&gt;Términos relacionados: Remake, Retro
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Mid-core Gamer&lt;/b&gt;&lt;br/&gt;
Del inglés Mid-core Gamer (Jugador intermedio).
&lt;br/&gt;&lt;br/&gt;
Perfil de jugador que se sitúa a medio camino entre un Casual Gamer y un Hardcore Gamer. Se caracteriza por preferir juegos que poseen la accesibilidad y las mecánicas jugables sencillas propias de los juegos casual pero acompañadas por los valores de producción, profundidad e inmersión de los juegos hardcore.
&lt;br&gt;
Por lo general se trata de un jugador con gran dedicación e interés por los videojuegos, como los hardcore gamers, pero que por falta de tiempo o aburrimiento ha dejado de prestar atención a los juegos propios de los hardcore.
&lt;br/&gt;
(Jugadores, Perfiles Gamers)&lt;br&gt;
Términos relacionados: Casual Gamer, Hardcore Gamer
&lt;br&gt;&lt;br&gt;
Uy, este último parece que encaja conmigo, ¡¡soy un Mid-core gamer!!</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/7757170857101640186/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-198.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7757170857101640186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7757170857101640186'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-198.html' title='Día 198'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMnd7b5dkX8titjUJWZ-mI5O09ROlX17nUBMvsA79zwddIRcTQYNwSA5G_kAV1YfSINRv0qMVBbJGEIk3_CFAn72SAeb1dT-yPl38cFUYERSz_ZAgM-yvZic01IpJI3v_ZJ3lSpMR41JGT/s72-c/left4dead2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-51779131832404902</id><published>2014-08-07T14:02:00.000+02:00</published><updated>2014-08-07T14:02:00.586+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asteroids"/><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="rice"/><category scheme="http://www.blogger.com/atom/ns#" term="ricerocks"/><category scheme="http://www.blogger.com/atom/ns#" term="rocks"/><title type='text'>RiceRocks en python</title><content type='html'>Juego de asteroids en python.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwmMyJZ0s_zdSj3tSs4LnedFx8pDU0FaNm7bVf9gyIB9okEV_SFVLPZxO4ahSFeVCE3qqd1SwJyUzlB-I_YA99Ghiz2hwcgsfHNvRnBz69hgPQ37PDYeWW2uUIPU-dkFUrZMrR2QgBbGvJ/s1600/ricerocks.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwmMyJZ0s_zdSj3tSs4LnedFx8pDU0FaNm7bVf9gyIB9okEV_SFVLPZxO4ahSFeVCE3qqd1SwJyUzlB-I_YA99Ghiz2hwcgsfHNvRnBz69hgPQ37PDYeWW2uUIPU-dkFUrZMrR2QgBbGvJ/s320/ricerocks.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
Con las teclas de dirección para moverse y el espacio para disparar es todo lo que necesitas para jugar.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;&lt;br&gt;
No es gran cosa, pero aún así ayuda en mi viaje ya que lo mejor de este código es haber aprendido cómo manejar las animaciones, su dibujado y su relación con el tiempo, aunque no nos hallamos metido con los conceptos de fps (frames per second/frames por segundo)
&lt;br/&gt;&lt;br&gt;
Una vez más, toca ejecutarlo en &lt;a href=&quot;http://www.codeskulptor.org/&quot;&gt;CodeSkulptor&lt;/a&gt; por la librería gráfica propia de la plataforma.
&lt;br&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
RiceRocks: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
import simplegui
import math
import random

# globals for user interface
WIDTH = 800
HEIGHT = 600
score = 0
lives = 3
time = 0
started = False
limit_rocks=12

class ImageInfo:
    def __init__(self, center, size, radius = 0, lifespan = None, animated = False):
        self.center = center
        self.size = size
        self.radius = radius
        if lifespan:
            self.lifespan = lifespan
        else:
            self.lifespan = float(&#39;inf&#39;)
        self.animated = animated

    def get_center(self):
        return self.center

    def get_size(self):
        return self.size

    def get_radius(self):
        return self.radius

    def get_lifespan(self):
        return self.lifespan

    def get_animated(self):
        return self.animated

    
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
    
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
#                 debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png&quot;)

# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2013.png&quot;)

# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png&quot;)

# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png&quot;)

# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 50)
missile_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/shot2.png&quot;)

# asteroid images - asteroid_blue.png, asteroid_brown.png, asteroid_blend.png
asteroid_info = ImageInfo([45, 45], [90, 90], 40)
asteroid_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/asteroid_blue.png&quot;)

# animated explosion - explosion_orange.png, explosion_blue.png, explosion_blue2.png, explosion_alpha.png
explosion_info = ImageInfo([64, 64], [128, 128], 17, 24, True)
explosion_image = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/explosion_alpha.png&quot;)

# sound assets purchased from sounddogs.com, please do not redistribute
# .ogg versions of sounds are also available, just replace .mp3 by .ogg
soundtrack = simplegui.load_sound(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/soundtrack.mp3&quot;)
missile_sound = simplegui.load_sound(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/missile.mp3&quot;)
missile_sound.set_volume(.5)
ship_thrust_sound = simplegui.load_sound(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3&quot;)
explosion_sound = simplegui.load_sound(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/explosion.mp3&quot;)

# helper functions to handle transformations
def angle_to_vector(ang):
    return [math.cos(ang), math.sin(ang)]

def dist(p, q):
    return math.sqrt((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2)


# Ship class
class Ship:

    def __init__(self, pos, vel, angle, image, info):
        self.pos = [pos[0], pos[1]]
        self.vel = [vel[0], vel[1]]
        self.thrust = False
        self.angle = angle
        self.angle_vel = 0
        self.image = image
        self.image_center = info.get_center()
        self.image_size = info.get_size()
        self.radius = info.get_radius()
        
    def get_position(self):
        return self.pos
    
    def get_radius(self):
        return self.radius
        
    def draw(self,canvas):
        if self.thrust:
            canvas.draw_image(self.image, [self.image_center[0] + self.image_size[0], self.image_center[1]] , self.image_size,
                              self.pos, self.image_size, self.angle)
        else:
            canvas.draw_image(self.image, self.image_center, self.image_size,
                              self.pos, self.image_size, self.angle)
        # canvas.draw_circle(self.pos, self.radius, 1, &quot;White&quot;, &quot;White&quot;)

    def update(self):
        # update angle
        self.angle += self.angle_vel
        
        # update position
        self.pos[0] = (self.pos[0] + self.vel[0]) % WIDTH
        self.pos[1] = (self.pos[1] + self.vel[1]) % HEIGHT

        # update velocity
        if self.thrust:
            acc = angle_to_vector(self.angle)
            self.vel[0] += acc[0] * .1
            self.vel[1] += acc[1] * .1
            
        self.vel[0] *= .99
        self.vel[1] *= .99

    def set_thrust(self, on):
        self.thrust = on
        if on:
            ship_thrust_sound.rewind()
            ship_thrust_sound.play()
        else:
            ship_thrust_sound.pause()
       
    def increment_angle_vel(self):
        self.angle_vel += .05
        
    def decrement_angle_vel(self):
        self.angle_vel -= .05
        
    def shoot(self):
        forward = angle_to_vector(self.angle)
        missile_pos = [self.pos[0] + self.radius * forward[0], self.pos[1] + self.radius * forward[1]]
        missile_vel = [self.vel[0] + 6 * forward[0], self.vel[1] + 6 * forward[1]]
        a_missile = Sprite(missile_pos, missile_vel, self.angle, 0, missile_image, missile_info, missile_sound)
        missiles.add(a_missile)
    
    
# Sprite class
class Sprite:
    def __init__(self, pos, vel, ang, ang_vel, image, info, sound = None):
        self.pos = [pos[0],pos[1]]
        self.vel = [vel[0],vel[1]]
        self.angle = ang
        self.angle_vel = ang_vel
        self.image = image
        self.image_center = info.get_center()
        self.image_size = info.get_size()
        self.radius = info.get_radius()
        self.lifespan = info.get_lifespan()
        self.animated = info.get_animated()
        self.age = 0
        if sound:
            sound.rewind()
            sound.play()
   
    def draw(self, canvas):
        canvas.draw_image(self.image, self.image_center, self.image_size,
                          self.pos, self.image_size, self.angle)

    def get_position(self):
        return self.pos
    
    def get_radius(self):
        return self.radius
        
    def update(self):
        # update angle
        self.angle += self.angle_vel
        
        # update position
        self.pos[0] = (self.pos[0] + self.vel[0]) % WIDTH
        self.pos[1] = (self.pos[1] + self.vel[1]) % HEIGHT
        
        if self.lifespan!=None:
            self.age=self.age+1
            if self.age&gt;self.lifespan:
                return True
            else:
                return False
        
    def collide(self, other_sprite):
        other_pos = other_sprite.get_position()
        other_rad = other_sprite.get_radius()        
        if dist(self.pos, other_pos) &lt; (other_rad + self.radius):
            return True
        else:
            return False

  
        
# key handlers to control ship   
def keydown(key):
    if key == simplegui.KEY_MAP[&#39;left&#39;]:
        my_ship.decrement_angle_vel()
    elif key == simplegui.KEY_MAP[&#39;right&#39;]:
        my_ship.increment_angle_vel()
    elif key == simplegui.KEY_MAP[&#39;up&#39;]:
        my_ship.set_thrust(True)
    elif key == simplegui.KEY_MAP[&#39;space&#39;]:
        my_ship.shoot()
        
def keyup(key):
    if key == simplegui.KEY_MAP[&#39;left&#39;]:
        my_ship.increment_angle_vel()
    elif key == simplegui.KEY_MAP[&#39;right&#39;]:
        my_ship.decrement_angle_vel()
    elif key == simplegui.KEY_MAP[&#39;up&#39;]:
        my_ship.set_thrust(False)
        
# mouseclick handlers that reset UI and conditions whether splash image is drawn
def click(pos):
    global started, timer
    center = [WIDTH / 2, HEIGHT / 2]
    size = splash_info.get_size()
    inwidth = (center[0] - size[0] / 2) &lt; pos[0] &lt; (center[0] + size[0] / 2)
    inheight = (center[1] - size[1] / 2) &lt; pos[1] &lt; (center[1] + size[1] / 2)
    if (not started) and inwidth and inheight:
        started = True
        timer.start()
        soundtrack.rewind()
        soundtrack.play()

def draw(canvas):
    global time, started, lives, score
    
    # animiate background
    time += 1
    wtime = (time / 4) % WIDTH
    center = debris_info.get_center()
    size = debris_info.get_size()
    canvas.draw_image(nebula_image, nebula_info.get_center(), nebula_info.get_size(), [WIDTH / 2, HEIGHT / 2], [WIDTH, HEIGHT])
    canvas.draw_image(debris_image, center, size, (wtime - WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT))
    canvas.draw_image(debris_image, center, size, (wtime + WIDTH / 2, HEIGHT / 2), (WIDTH, HEIGHT))

    if started:
        #if touched
        if collide_group(rocks, my_ship):
            lives=lives-1
            
        if lives==0:
            reset_game()

        number_hits=collide_two_group(rocks, missiles)
        score=score+number_hits*10


    # draw ship and sprites
    my_ship.draw(canvas)
    draw_set(rocks, canvas)
    draw_set(missiles, canvas)
    
    # update ship and sprites
    my_ship.update()
    
    # draw UI
    canvas.draw_text(&quot;Lives&quot;, [50, 50], 22, &quot;White&quot;)
    canvas.draw_text(&quot;Score&quot;, [680, 50], 22, &quot;White&quot;)
    canvas.draw_text(str(lives), [50, 80], 22, &quot;White&quot;)
    canvas.draw_text(str(score), [680, 80], 22, &quot;White&quot;)

    # draw splash screen if not started
    if not started:
        canvas.draw_image(splash_image, splash_info.get_center(), 
                          splash_info.get_size(), [WIDTH / 2, HEIGHT / 2], 
                          splash_info.get_size())

def draw_set(the_set, canvas):
    for element in list(the_set):
        element.draw(canvas)
        if element.update():
            the_set.remove(element)
        
# timer handler that spawns a rock    
def rock_spawner():
    global limit_rocks
    if limit_rocks&gt;len(rocks) :
        
        rock_pos = [random.randrange(0, WIDTH), random.randrange(0, HEIGHT)]
        rock_vel = [random.random() * .6 - .3, random.random() * .6 - .3]
        rock_avel = random.random() * .2 - .1
        new_rock = Sprite(rock_pos, rock_vel, 0, rock_avel, asteroid_image, asteroid_info)
        if new_rock.collide(my_ship):
            rock_spawner()
        else:
            rocks.add(new_rock)
    
    
def collide_group(the_set, element):
    for one_of_set in list(the_set):
        if one_of_set.collide(element):
            the_set.remove(one_of_set)
            return True
    return False
    
def collide_two_group(rock, missil):
    count_collide=0
    for one_rock in list(rock):
        for a_missil in list(missil):
            if one_rock.collide(a_missil):
                count_collide=count_collide+1
                missil.remove(a_missil)
                rock.remove(one_rock)
    return count_collide                

def reset_game():
    global lives, score,started, timer, number_rocks, rocks
    started=False
    number_rocks=0
    lives=3
    score=0
    rocks=set([])
    timer.stop()
    soundtrack.pause()
        
        
# initialize stuff
frame = simplegui.create_frame(&quot;Asteroids&quot;, WIDTH, HEIGHT)

# initialize ship and two sprites
my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0, ship_image, ship_info)
rocks=set([])
missiles=set([])

# register handlers
frame.set_keyup_handler(keyup)
frame.set_keydown_handler(keydown)
frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)

timer = simplegui.create_timer(1000.0, rock_spawner)

# get things rolling
frame.start()
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/51779131832404902/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/ricerocks-en-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/51779131832404902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/51779131832404902'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/ricerocks-en-python.html' title='RiceRocks en python'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwmMyJZ0s_zdSj3tSs4LnedFx8pDU0FaNm7bVf9gyIB9okEV_SFVLPZxO4ahSFeVCE3qqd1SwJyUzlB-I_YA99Ghiz2hwcgsfHNvRnBz69hgPQ37PDYeWW2uUIPU-dkFUrZMrR2QgBbGvJ/s72-c/ricerocks.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-5848336493285525374</id><published>2014-08-07T14:01:00.000+02:00</published><updated>2014-08-07T14:01:00.072+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="aprendizaje"/><category scheme="http://www.blogger.com/atom/ns#" term="coursera"/><category scheme="http://www.blogger.com/atom/ns#" term="gee"/><category scheme="http://www.blogger.com/atom/ns#" term="principios"/><title type='text'>Los 13 principios de Glee</title><content type='html'>De un majo hombre llamado James Paul Gee, un profesor de la universidad de Arizona, nos da unos trece principios sobre el aprendizaje en los videojuegos. Se parte de la idea de que el aprendizaje es en base a problemas.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNFNTr5xi747FYA__I9JAuzOh-FP0R8fcGJ8mVVW6T7EKMyQVl14aX_bvUOheSgORx31RKBamL916p-WQ8T3Vs8pG6o1xyUwPPtZst1nEoVU0UZ_325ycGufWzzPq7L-1b_F2P66OOuMWH/s320/donald-estudiando.gif&quot;/&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Principio del co-diseñador: El jugador debe sentir que lo que hace importa, es importante, ya que lo que haces, afecta al juego y también los resultados y cómo resuelves los problemas en el juego.&lt;/li&gt;

&lt;li&gt;Principio de la compresión como acción. La gente al aprender, asocian la palabra con una imagen, acción o experiencia. Eso se consigue si tienes algo más que palabras, si tienes experiencias, estás en el mundo (aunque sea simulado), no sirve simples definiciones o textos.&lt;/li&gt;

&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;

&lt;li&gt;Principio del arenero. Llamado así por la analogía de un terrario de arena donde los crios juegan, exploran, prueban cosas, experimentan... estando en un entorno protegido (o con riesgos bajos) y sin ser juzgados, rankeados o similar. Un ejemplo podría ser los Sims.&lt;/li&gt;

&lt;li&gt;Principio de la personalización. Los jugadores necesitan sentir que lo que hacen tiene sentido e importa. Lo que vendría a ser permitir diferentes tipos de jugadores, permitiendo ser lo que más les guste e incluso probar diferentes formas, estrategias, ser otro tipo de jugador distinto.&lt;/li&gt;

&lt;li&gt;Principio del tanque de peces. Si se tienen buenos problemas y difíciles, se tendrá complejidad. Si nos fijamos en el ecosistema, serán demasiadas cosas y demasiada complejidad para poder abarcarlo. Si vamos sacando cosas hacia una pecera, podemos ir viendo paso por paso como reaccionan e interactúan los elementos y poder ir añadiendo complejidad. En los juegos viene a ser los niveles de los personajes, en los que se va añadiendo dificultad o nuevas cosas.&lt;/li&gt;

&lt;li&gt;Principio de identidad. El principio del aprendizaje es saber en qué te vas a convertir y qué vas a conseguir si haces determinadas cosas y aprendes esas cosas. El jugador necesita saber porqué estás haciendo lo que haces, por ello el juego da un avatar, metas claras, y un claro sentimiento de quién eres/quién vas a ser.&lt;/li&gt;

&lt;li&gt;Principio de la frustración gratificante. Tan sencillo como que un buen problema significa que lo ves como un desafío, que te frustra un poco conseguirlo pero sabes que vas a conseguir una forma de resolverlo.&lt;/li&gt;

&lt;li&gt;Principio de la manipulación. La capacidad de manipulación del jugador en el juego, como es controlar al personaje.&lt;/li&gt;

&lt;li&gt;Principio de los problemas bien ordenados. Se entiende rápido cuando pensamos en tutoriales o en el juego en general, en el que empiezas resolviendo problemas sencillos, cuyo aprendizaje sirve luego para problemas más grandes y complejos. El orden importa.&lt;/li&gt;

&lt;li&gt;Principio en el momento y en demanda. Refiriéndose a en el momento a pequeñas piezas de información que puedes aplicar en el momento/lugar, mientras que en demanda se refiere más a las ayudas e informaciones más grandes de cuando te atascas y necesitas información, o simplemente quieres saber más, momento en el que estás preparado para recibir grandes cantidades de información.&lt;/li&gt;

&lt;li&gt;Principio del pensamiento sistemático. El jugador intenta hacerse un modelo de cómo el sistema (juego) funciona, sus reglas, variables y complejidad, para poder saber que puede y puede no hacer.&lt;/li&gt;

&lt;li&gt;Habilidades como estrategias. Un simple ejemplo, si en el juego eres un guerrero y estás simplemente pegando mandobles a cuatro gallinas, no tienes ni idea de qué haces, pero si sabes que tienes que matar a un gigante para conseguir la meta propuesta, la cosa cambia, ya que sabes que practicas los mandobles para conseguir dicha habilidad, siendo esa habilidad una estrategia para conseguir la meta.&lt;/li&gt;

&lt;li&gt;Principio del ciclo del experto, se da un problema al jugador, éste lo practica y con ello consigue un conocimiento y una práctica con la que se convierte en maestro y resuelve el problema sin dificultad, hasta que se le ofrece otro problema con el que no sirve dicho conocimiento y vuelta a empezar.&lt;/li&gt;
&lt;/ol&gt;

&lt;br /&gt;
Estos principios los he sacado del cursillo de Videojuegos y aprendizaje en &lt;a href=&quot;http://mundosdelvideojuego.blogspot.com.es/2014/02/cousera.html&quot;&gt;Coursera&lt;/a&gt;. Si os digo la verdad, ya van como cuatro veces que me veo los vídeos y trato de entender lo que quiere decir, y todavía no lo he conseguido. Y se nota en que esto no deja de ser una cutre traducción del inglés en el que muchas cosas no sabía ni cómo traducirlo.
&lt;br /&gt;
&lt;br /&gt;
Si alguien quiere dar su opinión sobre lo que quiere decir o lo que opina que serían mejor otros principios. ¡Adelante y comenta!</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/5848336493285525374/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/los-13-principios-de-glee.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5848336493285525374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5848336493285525374'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/los-13-principios-de-glee.html' title='Los 13 principios de Glee'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNFNTr5xi747FYA__I9JAuzOh-FP0R8fcGJ8mVVW6T7EKMyQVl14aX_bvUOheSgORx31RKBamL916p-WQ8T3Vs8pG6o1xyUwPPtZst1nEoVU0UZ_325ycGufWzzPq7L-1b_F2P66OOuMWH/s72-c/donald-estudiando.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-2208299157185577319</id><published>2014-08-07T14:00:00.000+02:00</published><updated>2014-08-07T14:00:01.130+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 124</title><content type='html'>Parece que veo el final del túnel, acabando ya con coursera, el cual me pensaré muy bien que siguientes cursos tomar, y compaginando con la universidad.
&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEU04Rv0d2wCtC29rNvmwIDcPsRHuhwUj2WbWAZIvmtkl1SFxF8qUbj4_1j2jo2of3KNeWLNX8vX-VnBuymdy5GejlXBwZBmPpntGX5zKTZpYSn6Y-mlt-l1Xj9HgXEhv0-LEEbVfz4kHO/s320/viaje.jpg&quot; /&gt;&lt;/div&gt;
&lt;br&gt;
Debería empezar a tener algo más de tiempo para dedicar al viaje y salir de la maldita posada donde me quedé atascado, atendiendo los problemas de Deimos y Lyria, y cumpliendo con mis obligaciones.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;&lt;br&gt;
Por cierto, Deimos y Lyria están perfectamente sanos y bastante protegidos, aunque miro de arroparlos un poco más por si acaso.
&lt;br&gt;&lt;br&gt;
Y nos vamos a unos términos más para culturizarnos:
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Pixel hunt&lt;/b&gt;&lt;br/&gt;
Del inglés pixel hunt (caza del píxel).
&lt;br/&gt;&lt;br/&gt;
Recorrer &quot;pixel a pixel&quot; la pantalla para encontrar un objeto con el que interactuar.
&lt;br&gt;
Es común en juegos de aventura point and click, donde los jugadores atascados en una situación en la que es difícil saber con qué partes del escenario del juego se puede interactuar, responden a menudo haciendo clic metódicamente por toda la pantalla hasta que encuentran algo.
&lt;br/&gt;
(En juego, Acciones)&lt;br&gt;
Términos relacionados: Pixel
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Tryhard&lt;/b&gt;&lt;br/&gt;
Del inglés try hard (esforzarse).
&lt;br/&gt;&lt;br/&gt;
Jugador perfeccionista que invierte una gran cantidad de esfuerzo y concentración en llevar a cabo una estrategia en la partida para ganar y que sufre si no sale todo de acuerdo a su plan.
&lt;br&gt;
Suelen ser criticados porque pueden llegar a ser bastante molestos al centrarse demasiado en obtener la victoria en lugar de en divertirse.
&lt;br&gt;
(Jugadores, League of Legends)
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;PTFO&lt;/b&gt;&lt;br/&gt;
Del inglés &quot;Play The Fucking Objective&quot; (Juega al Puto Objetivo).
&lt;br/&gt;&lt;br/&gt;
Expresión popularizada dentro del multijugador del juego Battlefield, y que usan algunos jugadores con sus compañeros de equipo cuando estos se centran más en matar enemigos que en cumplir el objetivo de la partida. 
&lt;br/&gt;
(Expresiones, juegos de Disparos, Battlefield)</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/2208299157185577319/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-124.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2208299157185577319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2208299157185577319'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-124.html' title='Día 124'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEU04Rv0d2wCtC29rNvmwIDcPsRHuhwUj2WbWAZIvmtkl1SFxF8qUbj4_1j2jo2of3KNeWLNX8vX-VnBuymdy5GejlXBwZBmPpntGX5zKTZpYSn6Y-mlt-l1Xj9HgXEhv0-LEEbVfz4kHO/s72-c/viaje.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-5108311920065106866</id><published>2014-08-06T14:07:00.000+02:00</published><updated>2014-08-06T14:07:00.476+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fotos"/><category scheme="http://www.blogger.com/atom/ns#" term="recordar"/><title type='text'>Por los ojos entra</title><content type='html'>Me he dado cuenta que mucho escribir por aquí, pero las cosas apenas se me quedan en la cabeza. ¿Alguien se acuerda ya del documento de diseño?
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH_1CSr_QhIl95wSQ4fF9G_X81DFr3Y2jS623uZ0niqNfgLuluPWJL4tB_gkv81RsF9IH3TNKz9KDbpMKFVN3aNYDS_u3DqOpISX5GzOWh2ABMRIN-HSnVGba_IT83eh84ottWyRyxPwuy/s1600/documento.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH_1CSr_QhIl95wSQ4fF9G_X81DFr3Y2jS623uZ0niqNfgLuluPWJL4tB_gkv81RsF9IH3TNKz9KDbpMKFVN3aNYDS_u3DqOpISX5GzOWh2ABMRIN-HSnVGba_IT83eh84ottWyRyxPwuy/s320/documento.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
Yo no, y no debería. No he gastado tiempo en ello para después olvidarlo y como si no hubiera hecho nada. Pero tengo una pequeña solución. Verlo todos los días, tenerlo siempre presente.
&lt;br&gt;&lt;br&gt;
Y es por eso que he cogido partes de lo que había escrito en el blog, lo he pasado a papel, y lo he colgado en la pared, delante mío. Todos los días estoy a la mesa, al ordenador, y todos los días lo miro y me acuerdo. Cada vez que abro un proyecto nuevo, un simple vistazo me recuerda la organización. Cada vez que veo un juego y hago un pequeño análisis, veo el documento de diseño y recuerdo todas las partes.
&lt;br&gt;&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiomwJ3bhqA2GbhGNIPqStkiD1svCnVbMhR9uv53xPPVgFZaROpZIRsLXDLPmj3-mHZbDIKgounSGf1DpcGrUeX0Hw79tr5c_dMev3vT9P8SeEE3HrnsEOJ3zu_OPj1pjdUUb_4sn6HA1v9/s1600/documento+de+dise%25C3%25B1o.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiomwJ3bhqA2GbhGNIPqStkiD1svCnVbMhR9uv53xPPVgFZaROpZIRsLXDLPmj3-mHZbDIKgounSGf1DpcGrUeX0Hw79tr5c_dMev3vT9P8SeEE3HrnsEOJ3zu_OPj1pjdUUb_4sn6HA1v9/s400/documento+de+dise%25C3%25B1o.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ww9LAVzgeq6LWSeoMQ7x3zYZK_v7t533XpNxCnFek-IemTPwHkrTzul800KofXmU-x7Iha2C-i2sPN7pAL-HFovopSoWyWnSi6Ac34FQkkNxJqgRPDN7QlAGBYiPRH52wGGCZv3lCA1F/s1600/proyecto.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2ww9LAVzgeq6LWSeoMQ7x3zYZK_v7t533XpNxCnFek-IemTPwHkrTzul800KofXmU-x7Iha2C-i2sPN7pAL-HFovopSoWyWnSi6Ac34FQkkNxJqgRPDN7QlAGBYiPRH52wGGCZv3lCA1F/s400/proyecto.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
Y si, me equivoqué al escribir python.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/5108311920065106866/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/por-los-ojos-entra.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5108311920065106866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5108311920065106866'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/por-los-ojos-entra.html' title='Por los ojos entra'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH_1CSr_QhIl95wSQ4fF9G_X81DFr3Y2jS623uZ0niqNfgLuluPWJL4tB_gkv81RsF9IH3TNKz9KDbpMKFVN3aNYDS_u3DqOpISX5GzOWh2ABMRIN-HSnVGba_IT83eh84ottWyRyxPwuy/s72-c/documento.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-516301186735930345</id><published>2014-08-06T14:01:00.000+02:00</published><updated>2014-08-06T14:01:00.360+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="blackjack"/><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Blackjack en python</title><content type='html'>Un mini, pero que mini (como todo hasta ahora) juego de Blackjack, sacado del ya conocido curso de coursera.
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW9u7dEsCZ8BbU6bCsHpBJV5gEycpc8RsdAGFb9-Njz-pVp-ZU4saBPtRw8oG8dgwZET8VBAAwN4-mWH4Wjiq7VIDjntsBCvfM8OfXhXBiNGCfb9Y1upt1pl1lFRUvc-LPr6wjRMfO7RDn/s1600/blackjack.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW9u7dEsCZ8BbU6bCsHpBJV5gEycpc8RsdAGFb9-Njz-pVp-ZU4saBPtRw8oG8dgwZET8VBAAwN4-mWH4Wjiq7VIDjntsBCvfM8OfXhXBiNGCfb9Y1upt1pl1lFRUvc-LPr6wjRMfO7RDn/s320/blackjack.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br&gt;
Las reglas son sencillas: las cartas J,Q y K valen diez puntos, los ases 10 o 1, y el resto por su número de carta. Tienes que intentar tener más puntos que el otro, sin pasarse de 21. De forma que puedes escoger que te de más cartas para tener más puntos, o quedarte con las que tienes.
&lt;br&gt;
&lt;br/&gt;
Una vez más, toca ejecutarlo en &lt;a href=&quot;http://www.codeskulptor.org/&quot;&gt;CodeSkulptor&lt;/a&gt; por la librería gráfica propia de la plataforma.
&lt;br&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Blackjack: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
# Mini-project #6 - Blackjack

import simplegui
import random

# load card sprite - 949x392 - source: jfitz.com
CARD_SIZE = (73, 98)
CARD_CENTER = (36.5, 49)
card_images = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png&quot;)

CARD_BACK_SIZE = (71, 96)
CARD_BACK_CENTER = (35.5, 48)
card_back = simplegui.load_image(&quot;http://commondatastorage.googleapis.com/codeskulptor-assets/card_back.png&quot;)    

# initialize some useful global variables
in_play = False
outcome = &quot;&quot;
score_dealer = 0
score_player = 0
the_deck =&quot;&quot;
dealer_hand=&quot;&quot;
my_hand=&quot;&quot;

# define globals for cards
SUITS = (&#39;C&#39;, &#39;S&#39;, &#39;H&#39;, &#39;D&#39;)
RANKS = (&#39;A&#39;, &#39;2&#39;, &#39;3&#39;, &#39;4&#39;, &#39;5&#39;, &#39;6&#39;, &#39;7&#39;, &#39;8&#39;, &#39;9&#39;, &#39;T&#39;, &#39;J&#39;, &#39;Q&#39;, &#39;K&#39;)
VALUES = {&#39;A&#39;:1, &#39;2&#39;:2, &#39;3&#39;:3, &#39;4&#39;:4, &#39;5&#39;:5, &#39;6&#39;:6, &#39;7&#39;:7, &#39;8&#39;:8, &#39;9&#39;:9, &#39;T&#39;:10, &#39;J&#39;:10, &#39;Q&#39;:10, &#39;K&#39;:10}


# define card class
class Card:
    def __init__(self, suit, rank):
        if (suit in SUITS) and (rank in RANKS):
            self.suit = suit
            self.rank = rank
        else:
            self.suit = None
            self.rank = None
            print &quot;Invalid card: &quot;, suit, rank

    def __str__(self):
        return self.suit + self.rank

    def get_suit(self):
        return self.suit

    def get_rank(self):
        return self.rank

    def draw(self, canvas, pos):
        card_loc = (CARD_CENTER[0] + CARD_SIZE[0] * RANKS.index(self.rank), 
                    CARD_CENTER[1] + CARD_SIZE[1] * SUITS.index(self.suit))
        canvas.draw_image(card_images, card_loc, CARD_SIZE, [pos[0] + CARD_CENTER[0], pos[1] + CARD_CENTER[1]], CARD_SIZE)
        
# define hand class
class Hand:
    def __init__(self):
        #list of cards of the hand
        self.cards=[]
        # value of the hand
        self.hand_value=0
        #has hand an ace?
        self.has_ace = False

    # return a string representation of a hand
    def __str__(self):
        result=&quot;Hand contains &quot;
        #for every card...
        for next in self.cards:
            result=result + &quot; &quot; + str(next)
        return result

    def add_card(self, card):
        # add a card object to a hand
        self.cards.append(card)
        #sum the value of the card
        self.hand_value=self.hand_value+VALUES[card.get_rank()]
        
        #check if i have an ace
        if card.get_rank() == RANKS[0]:
            self.has_ace=True

    def get_value(self):
        # count aces as 1, if the hand has an ace, then add 10 to hand value if it doesn&#39;t bust
        if self.has_ace == True:
            if self.hand_value+10 &lt;=21:
                return self.hand_value+10
        return self.hand_value
   
    def draw(self, canvas, pos):
        i=0
        #for every card...
        for next in self.cards:
            card_pos=((i * CARD_SIZE[0])+pos[0]+10*i, pos[1])
            next.draw(canvas, card_pos)
            i=i+1 #increase the position of the card
        
# define deck class 
class Deck:
    def __init__(self):
        #list of cards
        self.cards=[]
        #double for, every cards
        for rank in RANKS:
            for suit in SUITS:
                self.cards.append(Card(suit, rank))
                
    #remix the cards
    def shuffle(self):
        # shuffle the deck
        random.shuffle(self.cards)

    def deal_card(self):
        return self.cards.pop()
    
    def __str__(self):
        result=&quot;Deck contains &quot;
        #for every card...
        for next in self.cards:
            result=result + &quot; &quot; + str(next)
        return result


#define event handlers for buttons
def deal():
    global outcome, in_play, the_deck, dealer_hand, my_hand, score_dealer
    #reset the outcome
    outcome=&quot;&quot;
    #reset the deck and hands
    the_deck=Deck()
    the_deck.shuffle()
    dealer_hand=Hand()
    my_hand=Hand()
    
    #give the cards
    dealer_hand.add_card(the_deck.deal_card())
    dealer_hand.add_card(the_deck.deal_card())
    my_hand.add_card(the_deck.deal_card())
    my_hand.add_card(the_deck.deal_card())
    
    #check if was playing
    if in_play:
        score_dealer=score_dealer+1
    else:
        in_play=True

def hit():
    global score_dealer, in_play, outcome
    if in_play:
        #get a card
        my_hand.add_card(the_deck.deal_card())
        #check bust
        if my_hand.get_value()&gt;21:
            outcome=&quot;You went bust and lose&quot;
            score_dealer=score_dealer+1
            in_play=False
           
def stand():
    global outcome, score_dealer, score_player, in_play
    if in_play:
        #hit cards to dealer until value of 17 or higher
        while dealer_hand.get_value()&lt;17:
            dealer_hand.add_card(the_deck.deal_card())
            
        #check situation
        if dealer_hand.get_value()&gt;21:
            outcome=&quot;Dealer got busted. You win&quot;
            score_player=score_player+1
        elif dealer_hand.get_value()&gt;=my_hand.get_value():
            outcome=&quot;You lose&quot;
            score_dealer=score_dealer+1
        else:
            outcome=&quot;You win&quot;
            score_player=score_player+1
        
        in_play=False

# draw handler    
def draw(canvas):
    #title
    canvas.draw_text(&quot;Blackjack&quot;, [100, 70], 36, &quot;Blue&quot;)
    
    #message of hit or deal
    next_step=&quot;&quot;
    if in_play:
        next_step=&quot;Hit or stand?&quot;
    else:
        next_step=&quot;New deal?&quot;
        
    #title and cards of dealer
    canvas.draw_text(&quot;Dealer&quot;, [100, 130], 24, &quot;Black&quot;)
    canvas.draw_text(outcome, [220, 130], 24, &quot;Black&quot;)
    dealer_hand.draw(canvas, [100, 150])
    
    #title and cards of player
    canvas.draw_text(&quot;Player&quot;, [100, 370], 24, &quot;Black&quot;)
    canvas.draw_text(next_step, [220, 370], 24, &quot;Black&quot;)
    my_hand.draw(canvas, [100, 400])
    
    #score
    canvas.draw_text(&quot;Score &quot;, [440, 30], 24, &quot;Black&quot;)
    canvas.draw_text(&quot;Dealer: &quot;+str(score_dealer), [430, 50], 24, &quot;Black&quot;)
    canvas.draw_text(&quot;Player: &quot;+str(score_player), [430, 70], 24, &quot;Black&quot;)
    
    #if in play, hidde the card of dealer
    if in_play:
        pos=[100, 150]
        canvas.draw_image(card_back, CARD_BACK_CENTER, CARD_BACK_SIZE, [pos[0] + CARD_CENTER[0], pos[1] + CARD_CENTER[1]], CARD_SIZE)


# initialization frame
frame = simplegui.create_frame(&quot;Blackjack&quot;, 600, 600)
frame.set_canvas_background(&quot;Green&quot;)

#create buttons and canvas callback
frame.add_button(&quot;Deal&quot;, deal, 200)
frame.add_button(&quot;Hit&quot;,  hit, 200)
frame.add_button(&quot;Stand&quot;, stand, 200)
frame.set_draw_handler(draw)


# get things rolling
deal()
frame.start()
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/516301186735930345/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/blackjack-en-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/516301186735930345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/516301186735930345'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/blackjack-en-python.html' title='Blackjack en python'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW9u7dEsCZ8BbU6bCsHpBJV5gEycpc8RsdAGFb9-Njz-pVp-ZU4saBPtRw8oG8dgwZET8VBAAwN4-mWH4Wjiq7VIDjntsBCvfM8OfXhXBiNGCfb9Y1upt1pl1lFRUvc-LPr6wjRMfO7RDn/s72-c/blackjack.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-2084743081073652532</id><published>2014-08-06T14:00:00.000+02:00</published><updated>2014-08-06T14:00:00.222+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 115</title><content type='html'>Una vez más, espoleado y parece que empieza a surtir efecto.&lt;br&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJMrRPxrbYGy1wZWDz-larmLxwleZEhFBmtQ1tV8zEWDninHHh8wS-yW5e3YqIHvsNJCV8pc98nYvmUlL1iFLDE7z70zcll6WIi0r2BhoUbx5b6Z8x6GRqsDA-ndHPN4jAwZTTUe9xpaYV/s1600/link.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJMrRPxrbYGy1wZWDz-larmLxwleZEhFBmtQ1tV8zEWDninHHh8wS-yW5e3YqIHvsNJCV8pc98nYvmUlL1iFLDE7z70zcll6WIi0r2BhoUbx5b6Z8x6GRqsDA-ndHPN4jAwZTTUe9xpaYV/s320/link.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;center&gt;(&lt;a href=&quot;https://www.flickr.com/photos/vintz/5163157909/&quot;&gt;enlace del autor original&lt;/a&gt;)&lt;/center&gt;
&lt;br&gt;&lt;br&gt;
Todavía está en  mente los anteriores y hoy han aparecido dos más, otros compañeros están programando para IOS cosillas, pequeñas y poca cosa, pero están haciendo cosas y con página web y esas cosas.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Revisando los requisitos, veo que piden conocimientos de C++ y ejemplos de trabajo y proyectos en los que puedan ver la calidad y poder usarlos como modo de selección.
&lt;br&gt;&lt;br&gt;
Y me entra el miedo. Creo que ha sido esto último lo que me ha despertado, el temor a que me rechacen, tengo que conseguirlo como sea, tengo que hacer algo. Para ello necesito hacer muchas cosas que me permitan tener soltura para poder hacer unos pocos decentes con el que ganarme un puesto en el Máster.
&lt;br&gt;&lt;br&gt;
Efectivamente es mi sueño, pero no puedo permitirme sufrir contratiempos para ponerme las pilas, podrían tener daños irreparables y no puedo permitírmelo.
&lt;br&gt;&lt;br&gt;
¡Cojamos de nuevo la mochila!</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/2084743081073652532/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-115.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2084743081073652532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2084743081073652532'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/08/dia-115.html' title='Día 115'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJMrRPxrbYGy1wZWDz-larmLxwleZEhFBmtQ1tV8zEWDninHHh8wS-yW5e3YqIHvsNJCV8pc98nYvmUlL1iFLDE7z70zcll6WIi0r2BhoUbx5b6Z8x6GRqsDA-ndHPN4jAwZTTUe9xpaYV/s72-c/link.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-9102092655856447922</id><published>2014-02-22T15:12:00.002+01:00</published><updated>2014-06-28T14:49:48.832+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Análisis de recursos"/><category scheme="http://www.blogger.com/atom/ns#" term="coursera"/><category scheme="http://www.blogger.com/atom/ns#" term="Recursos"/><title type='text'>Coursera</title><content type='html'>Interesante plataforma que un profesor nos comentó en clase. Se trata de &lt;a href=&quot;https://www.coursera.org/&quot;&gt;Coursera&lt;/a&gt;.
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbSIK2TFa8KmpbJSKwyZqov5vJwtnqs8tQo-JU5XoVwPDuDPV9FAoEvOAKcJr-Z52hRJyve4IeVVyiUfybJZz-mmLpmOiy0oe1epfcssKFpg-YzDGUwoqjDmrRA5ZXb3xDxFZ5qU3DOOKS/s1600/coursera.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbSIK2TFa8KmpbJSKwyZqov5vJwtnqs8tQo-JU5XoVwPDuDPV9FAoEvOAKcJr-Z52hRJyve4IeVVyiUfybJZz-mmLpmOiy0oe1epfcssKFpg-YzDGUwoqjDmrRA5ZXb3xDxFZ5qU3DOOKS/s320/coursera.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
Sacado de la wikipedia:
&lt;blockquote&gt;Es una plataforma de educación virtual gratuita nacida en octubre de 2011 y desarrollada por académicos de la Universidad de Stanford con el fin de brindar oferta de educación masiva a la población mundial (Massive Online Open Course), con cursos en inglés y otros idiomas como el español, francés, italiano y chino. Coursera ofrece cursos gratis de temas variados a niveles universitarios pero abiertos a todos los sectores de la población.&lt;/blockquote&gt;
&lt;br/&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
No hay mucho más que añadir. Son gratuitos y te dan un certificado de haber hecho los cursos. Hay una variante en algunos cursos que puedes pagar por el curso (creo que no es mucho) y así poder obtener un certificado que es oficial y puede ser verificado. Pero el curso lo puedes tomar igualmente sin pagar.
&lt;br/&gt;&lt;br/&gt;
Su estilo es poner una serie de videos como clases a la semana, los cuales puedes ver cuando quieras, y cada semana, te ponen un test sobre dicho contenido y/o un trabajo. Algunos hacen un test/examen al final del curso.
&lt;br/&gt;&lt;br/&gt;
Lo que más me gusta es que subtitulan los vídeos, por lo que puedo tomar sin ningún problema las clases porque la mayoría las dan en inglés, pero también pueden ofrecer subtitulos en español.
&lt;br/&gt;&lt;br/&gt;
De momento estoy a la espera de un par de certificados y a ver si soy capaz de terminar uno tercero. A ver como son.
&lt;br/&gt;&lt;br/&gt;
No es que esté muy relacionado con mi viaje, pero es una gran fuente de conocimiento y hay muchas cosas sobre mi campo, incluyendo cosillas relacionadas sobre videojuegos, entre ellas, hice los cursos de introducción a python, que lo enseñaban haciendo minijuegos (casualmente los que llevo subiendo hace días jejeje), la enseñanza en videojuegos y C++ para C que lo dejé porque se pasó con la dificultad y no tenía tiempo.
&lt;br/&gt;&lt;br/&gt;
También había probado un cursillo de teoría de juegos (que resultó ser economía), otro de interfaces que sigo sin saber qué era ese curso y tratando de terminar egiptología, que es algo que me inspira mucho y me gusta bastante.
&lt;br/&gt;&lt;br/&gt;
Ya iré haciendo posts sobre los cursos que voy haciendo y mis impresiones sobre ellos, a ver que aprendo que me ayude para el camino.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/9102092655856447922/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/cousera.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/9102092655856447922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/9102092655856447922'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/cousera.html' title='Coursera'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbSIK2TFa8KmpbJSKwyZqov5vJwtnqs8tQo-JU5XoVwPDuDPV9FAoEvOAKcJr-Z52hRJyve4IeVVyiUfybJZz-mmLpmOiy0oe1epfcssKFpg-YzDGUwoqjDmrRA5ZXb3xDxFZ5qU3DOOKS/s72-c/coursera.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-8355072989731227257</id><published>2014-02-22T15:12:00.000+01:00</published><updated>2014-02-22T15:12:09.868+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="pong"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Pong en python</title><content type='html'>Creo que no necesita más descripción que el título. Las dos palas se controlan con s y w, y las flechas de dirección arriba y abajo. ¡A pasar el rato!
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-9sR_Wpzb5hJTraR8E2CT3duhfcMXRpA_Tw8LWGL0DBCVyGtR-q1LekRSaeyzZybdPqG0ZI5ANUXH89205ceidl_YgwS_AaLUvTLVvuhP81o2fl_UmtnVfkhWViAifzlfH2PLn4PB7h2N/s1600/pong.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-9sR_Wpzb5hJTraR8E2CT3duhfcMXRpA_Tw8LWGL0DBCVyGtR-q1LekRSaeyzZybdPqG0ZI5ANUXH89205ceidl_YgwS_AaLUvTLVvuhP81o2fl_UmtnVfkhWViAifzlfH2PLn4PB7h2N/s320/pong.gif&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;
Una vez más, toca ejecutarlo en &lt;a href=&quot;http://www.codeskulptor.org/&quot;&gt;CodeSkulptor&lt;/a&gt; por la librería gráfica propia de la plataforma.

&lt;br/&gt;&lt;br/&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Pong: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
# Implementation of classic arcade game Pong

import simplegui
import random

# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400       
BALL_RADIUS = 20
PAD_WIDTH = 8
PAD_HEIGHT = 80
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
LEFT = False
RIGHT = True

#position[x,y] and velocity[x,y] of ball
ball_pos=[0,0]
ball_vel=[0,0]

#position[x,y] and velocity[x,y] of paddles
paddle_pos=[HEIGHT/2,HEIGHT/2]
paddle_vel=[0,0]

#score[left,rigth]
score=[0,0]

# initialize ball_pos and ball_vel for new bal in middle of table
# if direction is RIGHT, the ball&#39;s velocity is upper right, else upper left
def spawn_ball(direction):
    global ball_pos, ball_vel # these are vectors stored as lists
    ball_pos = [WIDTH/2, HEIGHT/2]
    ball_vel[0]=random.randrange(2, 4);
    ball_vel[1]=-1*random.randrange(1, 3);
    if direction==LEFT:
        ball_vel[0] =-1*ball_vel[0]


# define event handlers
def new_game():
    global score, paddle_pos
    score=[0,0]
    paddle_pos=[HEIGHT/2,HEIGHT/2]
    spawn_ball(LEFT)

#draw
def draw(c):
    # draw mid line and gutters
    c.draw_line([WIDTH / 2, 0],[WIDTH / 2, HEIGHT], 1, &quot;White&quot;)
    c.draw_line([PAD_WIDTH, 0],[PAD_WIDTH, HEIGHT], 1, &quot;White&quot;)
    c.draw_line([WIDTH - PAD_WIDTH, 0],[WIDTH - PAD_WIDTH, HEIGHT], 1, &quot;White&quot;)     
    # update ball
    new_position_ball()
            
    # draw ball
    c.draw_circle(ball_pos,BALL_RADIUS,2,&quot;White&quot;,&quot;White&quot;)
    
    # update paddle&#39;s vertical position, keep paddle on the screen
    modify_paddle(0)
    modify_paddle(1)
    
    # draw paddles
    c.draw_polygon(rectangle_paddle(0,paddle_pos[0]), 1, &quot;White&quot;, &quot;White&quot;)
    c.draw_polygon(rectangle_paddle(1,paddle_pos[1]), 1, &quot;White&quot;, &quot;White&quot;)
    
    #check the colision
    colision()
    
    # draw scores
    c.draw_text(str(score[0]),[WIDTH*(1/3.0),120],50, &quot;Green&quot;)
    c.draw_text(str(score[1]),[WIDTH*(2/3.0),120],50, &quot;Green&quot;)
     
#increase and decrease the velocity of paddles
def keydown(key):
    if key==simplegui.KEY_MAP[&quot;s&quot;]:
        paddle_vel[0]+=5
    elif key==simplegui.KEY_MAP[&quot;w&quot;]:
        paddle_vel[0]-=5
    elif key==simplegui.KEY_MAP[&quot;down&quot;]:
        paddle_vel[1]+=5
    elif key==simplegui.KEY_MAP[&quot;up&quot;]:
        paddle_vel[1]-=5
   
def keyup(key):
    if key==simplegui.KEY_MAP[&quot;s&quot;]:
        paddle_vel[0]-=5
    elif key==simplegui.KEY_MAP[&quot;w&quot;]:
        paddle_vel[0]+=5
    elif key==simplegui.KEY_MAP[&quot;down&quot;]:
        paddle_vel[1]-=5
    elif key==simplegui.KEY_MAP[&quot;up&quot;]:
        paddle_vel[1]+=5
        
#check if ball have colision with the paddle or the edge
def colision():
    #get the limits of paddle
    rigth_limit=WIDTH-PAD_WIDTH-BALL_RADIUS
    left_limit=PAD_WIDTH+BALL_RADIUS
    
    #check if ball colide with the edge
    if ball_pos[0]&gt;=rigth_limit:
        #if yes, check the position of the paddle to increase velocity or score
        if colision_with_ball(paddle_pos[1])==1:
            ball_vel[0]+=ball_vel[0]*0.10
            ball_vel[1]+=ball_vel[1]*0.10
        else:
            score[0]+=1
            spawn_ball(LEFT)
        
    #check if ball colide with the edge
    elif ball_pos[0]&lt;= left_limit:
        #if yes, check the position of the paddle to increase velocity or score
        if colision_with_ball(paddle_pos[0])==1:
            ball_vel[0]+=ball_vel[0]*0.10
            ball_vel[1]+=ball_vel[1]*0.10
        else:
            score[1]+=1
            spawn_ball(RIGHT)
            
#check if ball colides with the paddle
#return 1 if colides, 0 otherwise
def colision_with_ball(y):
    if ball_pos[1]&lt;=y+HALF_PAD_HEIGHT and ball_pos[1]&gt;=y-HALF_PAD_HEIGHT:
        return 1
    else:
        return 0

#move the paddle
def modify_paddle(paddle):
    upperPosition=paddle_pos[paddle]+paddle_vel[paddle]-HALF_PAD_HEIGHT
    downPosition=paddle_pos[paddle]+paddle_vel[paddle]+HALF_PAD_HEIGHT
    if not(upperPosition&lt;0 or downPosition&gt;HEIGHT):
            paddle_pos[paddle]+=paddle_vel[paddle]

#get the rectangle of paddle
def rectangle_paddle(position,y):
    point = [[0,0],[0,0],[0,0],[0,0]]
    side=0
    if position&gt;0:
        side=WIDTH-PAD_WIDTH
        
    point[0] = [side, y-HALF_PAD_HEIGHT]
    point[1] = [side+PAD_WIDTH, y-HALF_PAD_HEIGHT]
    point[2] = [side+PAD_WIDTH, y+HALF_PAD_HEIGHT]
    point[3] = [side, y+HALF_PAD_HEIGHT]
    
    return point   

#update position ball
def new_position_ball():
    ball_pos[0] += ball_vel[0]
    ball_pos[1] += ball_vel[1]
    
    under_limit=HEIGHT-BALL_RADIUS
    upper_limit=BALL_RADIUS
    rigth_limit=WIDTH-PAD_WIDTH-BALL_RADIUS
    left_limit=PAD_WIDTH+BALL_RADIUS
    
    if ball_pos[0]&gt;=rigth_limit:
        ball_vel[0]*=-1
        ball_pos[0]=rigth_limit
    elif ball_pos[0]&lt;= left_limit:
        ball_vel[0]*=-1
        ball_pos[0]=left_limit
        
    if ball_pos[1]&gt;=under_limit:
        ball_vel[1]*=-1
        ball_pos[1]=under_limit
    elif ball_pos[1]&lt;=upper_limit:
        ball_pos[1]=upper_limit
        ball_vel[1]*=-1
            


# create frame
frame = simplegui.create_frame(&quot;Pong&quot;, WIDTH, HEIGHT)
frame.set_draw_handler(draw)
frame.set_keydown_handler(keydown)
frame.set_keyup_handler(keyup)
frame.add_button(&quot;Reset&quot;, new_game)


# start frame
new_game()
frame.start()
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/8355072989731227257/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/pong-en-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/8355072989731227257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/8355072989731227257'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/pong-en-python.html' title='Pong en python'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-9sR_Wpzb5hJTraR8E2CT3duhfcMXRpA_Tw8LWGL0DBCVyGtR-q1LekRSaeyzZybdPqG0ZI5ANUXH89205ceidl_YgwS_AaLUvTLVvuhP81o2fl_UmtnVfkhWViAifzlfH2PLn4PB7h2N/s72-c/pong.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-5203166245645033205</id><published>2014-02-22T15:11:00.000+01:00</published><updated>2014-02-22T15:11:58.095+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 114</title><content type='html'>El juego que me inspiró, Faraón. Un gran juego que marcó mi vida y es la bandera de mi sueño. Su música no me deja indiferente y no soy capaz de expresar lo que esa música despierta en mí.
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Hjqp1wn4abirYRTcMdaO_sB3HO_P78tpVfd5JR7HNkWYamv2O5350v1FHNeO8Swg9f2_rVTOwHIRLRb7mDNkBF8T-Me3Py7lqlmSSLD_5N6yhRB0yF_5XfTMLw0PKV8xuVq4QaesiNGr/s1600/Pharaoh_Coverart.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Hjqp1wn4abirYRTcMdaO_sB3HO_P78tpVfd5JR7HNkWYamv2O5350v1FHNeO8Swg9f2_rVTOwHIRLRb7mDNkBF8T-Me3Py7lqlmSSLD_5N6yhRB0yF_5XfTMLw0PKV8xuVq4QaesiNGr/s320/Pharaoh_Coverart.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
Hoy no hubo nada nuevo, pero he sido de nuevo espoleado para reaccionar de una vez. ¿Cuánto ya de la última vez que actualicé? Mucho, como si mi sueño no fuera tal y no me interesara.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;Trabajo fin de grado son las palabras claves. El final de la carrera no anda tan lejos y eso implica que ya antes de terminar, tengo que vigilar el máster de videojuegos. Un máster que se supone que hará mi sueño realidad.
&lt;br/&gt;&lt;br/&gt;
Pero antes de eso, tendré que hacer el trabajo fin de grado, y la verdad es que no tengo la más mínima idea de que hacerlo. Tan sólo que tiene que ser un trabajo decente, un trabajo o proyecto que destaque y, a ser posible, relacionado con lo que quiero hacer.
&lt;br/&gt;&lt;br/&gt;
Hoy me enteré de un fichero en las que se ofertaban unos TFG y les eché un vistazo. La verdad es que no hay muchos que me llamen la atención, y de videojuegos sólo encontré dos, uno de ellos, el más interesante, es un trabajo sobre OpenGL. Y lo mejor, lo lleva una profesora que me parece buena y con la que tengo cierta confianza. La verdad es que me haría ilusión tenerla de tutora para el TFG y encima de algo que se relaciona con lo mío.
&lt;br/&gt;&lt;br/&gt;
Todavía tengo que pensar muy bien que haré, y me tomaré mi tiempo para decidir. Pero me han dado unas locas ganas de mirarme OpenGL e ir haciendo algo. Lo que sea para tener algo hecho y poder de verdad hacer algo bueno.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/5203166245645033205/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/dia-114.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5203166245645033205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5203166245645033205'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2014/02/dia-114.html' title='Día 114'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Hjqp1wn4abirYRTcMdaO_sB3HO_P78tpVfd5JR7HNkWYamv2O5350v1FHNeO8Swg9f2_rVTOwHIRLRb7mDNkBF8T-Me3Py7lqlmSSLD_5N6yhRB0yF_5XfTMLw0PKV8xuVq4QaesiNGr/s72-c/Pharaoh_Coverart.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-5270428865113053653</id><published>2013-12-06T21:14:00.001+01:00</published><updated>2013-12-06T21:14:59.705+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cronómetro"/><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>El cronómetro en python</title><content type='html'>Siguiendo con los minijuegos en python, traigo el cronómetro, el cual consiste en tratar de parar el reloj en el segundo exacto (2.0 y no 2.1).
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYuz7j3DvkGUnLvb8En5t318V2whEbrBnOl8EQUQnWAN344IjlESi5JUsP-bP8dRsjNDlU2Rpe24gryPXgYun8q7sty7GP4VWEcWtoOHpqX7gmQiPd5F5J334lig9zHHUF211_SLcUcL-/s1600/stopwatch.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYuz7j3DvkGUnLvb8En5t318V2whEbrBnOl8EQUQnWAN344IjlESi5JUsP-bP8dRsjNDlU2Rpe24gryPXgYun8q7sty7GP4VWEcWtoOHpqX7gmQiPd5F5J334lig9zHHUF211_SLcUcL-/s320/stopwatch.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;
Os recuerdo que usa una librería concreta del curso donde los hago, por lo que necesitáis copiar el código en &lt;a href=&quot;http://www.codeskulptor.org/&quot;&gt;CodeSkulptor&lt;/a&gt; para hacerlo funcionar.
&lt;br/&gt;&lt;br/&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Cronómetro: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
# template for &quot;Stopwatch: The Game&quot;
#import the graphics
import simplegui

# define global variables
#time
miliseconds = 0
#success/attempts
success=0
attempts=0

# format time into formatted string A:BC.D
def format(t):
    #take the parts of the time
    miliseconds = t % 10
    seconds = (t/10) % 60 # 60 seconds is a minute
    minutes = (t/600) % 10
    #first the minutes
    time=str(minutes)+ &quot;:&quot;
    #check if neccessary to put another digit(zero)
    if seconds&lt;10:
        time=time+ &quot;0&quot;
    # concat the rest of the formatted string
    time=time + str(seconds) + &quot;.&quot; + str(miliseconds)
    return time
    
    
# define event handlers for buttons; &quot;Start&quot;, &quot;Stop&quot;, &quot;Reset&quot;
# Start
def start():
    stopwatch.start()
    
#Stop
def stop():
    #check if is was running before make modifications
    if stopwatch.is_running():
        global attempts, success
        stopwatch.stop()
        #the method returns 1 if succes, 0 otherwise
        success=success + stop_at_second(miliseconds)
        attempts+=1
 
# Reset
def reset():
    global miliseconds, attempts
    stopwatch.stop()
    miliseconds=0
    attempts=0
    
# define succcess, return 1 if success, 0 otherwise
def stop_at_second(miliseconds):
    second = miliseconds % 10
    if second==0:
        return 1
    else:
        return 0

# define event handler for timer with 0.1 sec interval
def tick():
    global miliseconds
    #only count miliseconds if clock is running
    if stopwatch.is_running():
        miliseconds=miliseconds+1

# define draw handler
def draw(canvas):
    #get clock
    clock=format(miliseconds)
    #show clock and success
    canvas.draw_text(clock, [95,200], 54, &quot;White&quot;)
    canvas.draw_text(str(success)+&quot;/&quot;+str(attempts), [230,30], 26, &quot;Green&quot;)
    
# create frame
frame=simplegui.create_frame(&quot;Stopwatch&quot;, 300, 300)

# register event handlers
stopwatch=simplegui.create_timer(100, tick)

frame.add_button(&quot;Start&quot;, start, 200)
frame.add_button(&quot;Stop&quot;, stop, 200)
frame.add_button(&quot;Reset&quot;, reset, 200)
frame.set_draw_handler(draw)

# start frame
frame.start()
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/5270428865113053653/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/el-cronometro-en-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5270428865113053653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5270428865113053653'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/el-cronometro-en-python.html' title='El cronómetro en python'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOYuz7j3DvkGUnLvb8En5t318V2whEbrBnOl8EQUQnWAN344IjlESi5JUsP-bP8dRsjNDlU2Rpe24gryPXgYun8q7sty7GP4VWEcWtoOHpqX7gmQiPd5F5J334lig9zHHUF211_SLcUcL-/s72-c/stopwatch.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-362538516577478343</id><published>2013-12-06T21:14:00.000+01:00</published><updated>2013-12-06T21:14:18.809+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="adivina un numero"/><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="guess a number"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><title type='text'>Adivina el número en python</title><content type='html'>Código en python del sencillo juego de adivinar el número. Como siempre, lo hice pilladísimo de tiempo, asi que el código sigue siendo mierdecilla pinchada en un palo. Pero al menos hay código existente.
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEineCSKIcNph7mNtpQG2pjJqZ_ukwJjy8dDJ6AmAVuJ04Hu-fUZU_4VBuPG86csk4L6YkaxWcARYIR0ADMFt6HzoknZ9bcbk3fnZr7gjRtHzeR0a1YG2jeOKMfJ5rE9MpxUD0eNrvyv34-1/s1600/Numbers.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEineCSKIcNph7mNtpQG2pjJqZ_ukwJjy8dDJ6AmAVuJ04Hu-fUZU_4VBuPG86csk4L6YkaxWcARYIR0ADMFt6HzoknZ9bcbk3fnZr7gjRtHzeR0a1YG2jeOKMfJ5rE9MpxUD0eNrvyv34-1/s320/Numbers.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
En este proyecto ya hay un pequeño problema, y es que este código está hecho con el cursillo de coursera, el cual usan una plataforma propia donde podemos escribir y ejecutar python. Al ser de introducción y demás, resolvieron la parte gráfica ofreciendo una librería desarrollada por ellos en la plataforma para que no tengamos que preocuparnos de ello.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
Resultado, este código no es portable y si queréis ver el código en funcionamiento, tenéis que ir a &lt;a href=&quot;http://www.codeskulptor.org/&quot;&gt;CodeSkulptor&lt;/a&gt; y pegar el código. De CodeSkulptor sale la librería gráfica que aparece en el código.
&lt;br/&gt;&lt;br/&gt;
Tampoco os emocionéis con esto de los gráficos, que no dibujamos nada aquí. :P
&lt;br/&gt;&lt;br/&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Guess a number: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
#import the library for gui, random numbers and maths
import simplegui
import random
import math

#Global variables
# secret number
secret_number = 0
# attempts remaining
attempts = 0
# maximum of the range
maximum_range=100


# start new game
def new_game():
    global secret_number
    global attempts

    print
    #set a secret number
    secret_number = random.randrange(0,maximum_range)
    #set attempts according the range
    #with logarithm base 2 of the maximum (and ceiling)
    #I get the best number of attempts
    attempts = int(math.ceil(math.log(maximum_range,2)))
    
    #show the range of the game and the attempts
    print &quot;Range is [0,&quot; + str(maximum_range)+&quot;)&quot;
    print &quot;Number of attempts: &quot; + str(attempts)
    print

# define event handlers for control panel
def range100():
    # button that changes range to range [0,100) and restarts
    global maximum_range
    maximum_range=100
    new_game()

def range1000():
    # button that changes range to range [0,1000) and restarts
    global maximum_range
    maximum_range=1000
    new_game()
    
#Guess of the user, main of the game
def input_guess(guess):
    #show what I write
    print &quot;Guess was &quot; + guess
    
    #Error if is not a number(digit)
    if not guess.isdigit():
        print &quot;Write a number!&quot;
        
    else:
        #convert the string to int for comparison
        number = int(guess)
        #control the range
        if number&gt;=0 and number&lt;maximum_range :
            #in range, call another function
            where_is_secret_number(number)
        else:
            #not in range
            print &quot;Bad input, range is: [0,&quot; + str(maximum_range) + &quot;)&quot; 
    #print a space
    print
    #clear the input by writting nothing, I stored the input before
    #so now I can access to it
    input_text.set_text(&quot;&quot;)
    
#Compare the secret number with the guessed number
def where_is_secret_number(number):
    global attempts
    
    #compare if I won
    if number==secret_number:
        print &quot;You won!! The number is: &quot; + str(number)
        #start a new game
        new_game()
        
    else:
        #one less attempts and show it
        attempts-=1
        print &quot;Number of remaining guesses: &quot; + str(attempts)
        
        #if no more attempts, I loose and restart game
        if attempts==0:
            print &quot;You loose, the number was: &quot; + str(secret_number)
            new_game()
            
        #if I have attempts, show where is the number
        elif number&gt;secret_number:
            print &quot;Lower&quot;
        else:
            print &quot;Higher&quot;
    
# create frame
frame = simplegui.create_frame(&quot;Guess a number!&quot;, 200, 200)

# register event handlers for control elements
frame.add_button(&quot;Range is [0,100)&quot;, range100, 200) 
frame.add_button(&quot;Range is [0,1000)&quot;, range1000, 200)
#I store the input, so later I can clear the text inside the input
input_text=frame.add_input(&quot;Enter a guess&quot;, input_guess, 200)

# call new_game and start frame
new_game()
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/362538516577478343/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/adivina-el-numero-en-python.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/362538516577478343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/362538516577478343'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/adivina-el-numero-en-python.html' title='Adivina el número en python'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEineCSKIcNph7mNtpQG2pjJqZ_ukwJjy8dDJ6AmAVuJ04Hu-fUZU_4VBuPG86csk4L6YkaxWcARYIR0ADMFt6HzoknZ9bcbk3fnZr7gjRtHzeR0a1YG2jeOKMfJ5rE9MpxUD0eNrvyv34-1/s72-c/Numbers.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-6077833937176021610</id><published>2013-12-06T21:13:00.000+01:00</published><updated>2014-06-28T19:04:42.643+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="make"/><category scheme="http://www.blogger.com/atom/ns#" term="makefile"/><category scheme="http://www.blogger.com/atom/ns#" term="Material de teoría"/><title type='text'>Make I</title><content type='html'>Algo muy útil para los proyectos y que los IDE (programas que ayudan a programar) hacen de forma automática, son los makefiles. Make es una orden que se aplica a cualquier tarea donde algunos ficheros deben ser actualizados a partir de otros cuando éstos cambian.
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnkod02pqq_cjqRDp5nxtA6pyK9NIcasciqXjZWLGLCnKLZdcEUzTST2z4ZzbB8DbqRdvE7VXJBygZDnh4fO5JFZTZUhWR_ygIes9K-77Xe0wL7DhevTmK13jjt2HG05lkb1EepD1l4_jF/s1600/apache-compile-wallpaper-dark.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnkod02pqq_cjqRDp5nxtA6pyK9NIcasciqXjZWLGLCnKLZdcEUzTST2z4ZzbB8DbqRdvE7VXJBygZDnh4fO5JFZTZUhWR_ygIes9K-77Xe0wL7DhevTmK13jjt2HG05lkb1EepD1l4_jF/s320/apache-compile-wallpaper-dark.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
Se basa un un fichero makefile donde se describen las relaciones entre los ficheros que componen el programa y las órdenes necesarias para cada uno de ellos. De forma automática actualiza sólo lo necesario, lo que haya cambiado y no todo.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;
&lt;blockquote&gt;
#make de un programa&lt;br/&gt;
programa: objetivo2, objetivo3&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden&lt;/span&gt;
&lt;br/&gt;&lt;br/&gt;
objetivo2: objetivo3&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden&lt;/span&gt;
&lt;br/&gt;&lt;br/&gt;
objetivo3:&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;comando orden demasiado largo pero que muy largo \&lt;/span&gt;&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;y el comando sigue en la segunda línea&lt;/span&gt;
&lt;/blockquote&gt;
&lt;br/&gt;&lt;br/&gt;

&lt;ul&gt;
&lt;li&gt;Cada fichero del programa es un objetivo (target) de una regla, menos cabeceras y fuentes.&lt;/li&gt;
&lt;li&gt;Cada objetivo aparece al principio de una línea seguido de dos puntos (:) y a continuación las dependencias (lo que necesita previamente).&lt;/li&gt;
&lt;li&gt;Tras cada objetivo e indentados con tabulaciones, van las ordenes.&lt;/li&gt;
&lt;li&gt;Make comienza con la primera regla que encuentra, por lo que se suele empezar con  el programa en sí, ya que de él depende todo lo demás.&lt;/li&gt;
&lt;li&gt;Si una línea es muy larga, se puede dividir en dos con \&lt;/li&gt;
&lt;li&gt;Para poner comentarios se colocan después de #&lt;/li&gt;
&lt;/ul&gt;


A veces hay objetivos/dependencias que se repiten, por lo que podemos guardarlos en una variable
&lt;blockquote&gt;variable= dependencia1.o cabecera1.h
objetivo1: $(variable)&lt;br/&gt;
&lt;span class=&quot;tab&quot;&gt;orden ${variable}&lt;/span&gt;&lt;/blockquote&gt;
Para usar la variable se puede usar tanto los paréntesis como las llaves.&lt;br/&gt;
Podemos usarlo en las dependencias o en las órdenes de la regla.
&lt;br/&gt;&lt;br/&gt;
A veces sólo especificamos las dependencias (no hay órdenes) y vemos que para varios objetos, las dependencias se repiten. Se pueden agrupar de otra forma, pasando de varias líneas a unas pocas. Por ejemplo:
&lt;blockquote&gt;
objetivo1: cabecera1.h cabecera2.h &lt;br/&gt;
objetivo2: cabecera1.h cabecera2.h&lt;br/&gt;
objetivo3: cabecera1.h cabecera2.h&lt;br/&gt;
objetivo4: cabecera1.h cabecera2.h&lt;br/&gt;
&lt;br/&gt;&lt;br/&gt;
objetivo1 objetivo2 objetivo3 objetivo4: cabecera1.h cabecera2.h
&lt;/blockquote&gt;
&lt;br/&gt;&lt;br/&gt;
Esta es la estructura básica y general de un makefile. El próximo día empezamos a hablar de las órdenes y de más cosas que tiene.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/6077833937176021610/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/make-i.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/6077833937176021610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/6077833937176021610'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/make-i.html' title='Make I'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnkod02pqq_cjqRDp5nxtA6pyK9NIcasciqXjZWLGLCnKLZdcEUzTST2z4ZzbB8DbqRdvE7VXJBygZDnh4fO5JFZTZUhWR_ygIes9K-77Xe0wL7DhevTmK13jjt2HG05lkb1EepD1l4_jF/s72-c/apache-compile-wallpaper-dark.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-20683701918413392</id><published>2013-12-06T21:12:00.000+01:00</published><updated>2013-12-06T21:12:51.745+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 109</title><content type='html'>Un día malo y de cabreo para mí... tanto tiempo estudiando y tanto tiempo desperdiciado porque no hay manera de concentrarse. Junta esto con Tweetalk y mi prácticamente abandono del blog, y ¡toma coctelera!
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbOs9tClzS_UyYG6eboTopnZFs35i03_Dwpho0qgzyVkGMPkYDLnLYEdhHwiTMjQyUPWxfG70O8kjKbhUgb13crDigo74U1aTjEFNcxm_MVQyMzFVrCmEkiCA64nRcXOajW2CpJe5uobq1/s1600/descanso2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbOs9tClzS_UyYG6eboTopnZFs35i03_Dwpho0qgzyVkGMPkYDLnLYEdhHwiTMjQyUPWxfG70O8kjKbhUgb13crDigo74U1aTjEFNcxm_MVQyMzFVrCmEkiCA64nRcXOajW2CpJe5uobq1/s320/descanso2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
Voy a seguir otra estrategia, ya que veo que apenas actualizo, pero si voy haciendo algunos avances, voy al menos dejarme apuntes para que cuando actualice, ponga todo, de ahí que los días transcurridos, no coincidirán con el conteo del calendario, pero sí con la realidad.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;
Y hoy toca hablar de &lt;a href=&quot;https://tweetalk.co/&quot;&gt;tweetalk&lt;/a&gt;, un servicio que te permite chatear con tus seguidores de Twitter. En el enlace tenéis una mejor explicación y la verdad es que merece la pena. Lo han hecho un par de compañeros míos de la universidad y hay que reconocerles un trabajo bastante bien hecho, con certificado de seguridad y todo.
&lt;br/&gt;&lt;br/&gt;
¿Conocéis ese sentimiento llamado envidia? Habéis acertado, tengo envidia, pero de la buena. Hay gente que piensa que no existe la envidia buena, que esa no es envidia, sino admiración. Sea lo que sea, me alegro por ellos, se lo han currado. Mi envidia viene de que me gustaría poder alcanzar yo también algo así, un servicio, una aplicación, un juego... lo que sea. Esa forma de trabajar y destacar con algo que pueda llegar muy lejos.
&lt;br/&gt;&lt;br/&gt;
Cosas así, después de tanta gente diciendo que yo lo valgo, que yo puedo hacer algo así, que cómo es que no se me ha ocurrido a mí y no lo he hecho, hace que me sienta inútil. Y si veo el trabajo que he reflejado en el blog, sigo pensando en que soy inútil y además en que quizás no es tanto mi sueño como pensaba. Pero incluso así, sigo pensando que es mi sueño y ahí quiero llegar, ¿quizás estoy demasiado seguro de que llegaré pase lo que pase?
&lt;br/&gt;&lt;br/&gt;
Dependo demasiado de las palabras de ánimo de los demás. El mío no me hace efecto.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/20683701918413392/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/dia-109.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/20683701918413392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/20683701918413392'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/12/dia-109.html' title='Día 109'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbOs9tClzS_UyYG6eboTopnZFs35i03_Dwpho0qgzyVkGMPkYDLnLYEdhHwiTMjQyUPWxfG70O8kjKbhUgb13crDigo74U1aTjEFNcxm_MVQyMzFVrCmEkiCA64nRcXOajW2CpJe5uobq1/s72-c/descanso2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-386260206170558453</id><published>2013-10-25T23:28:00.001+02:00</published><updated>2013-11-28T23:32:26.065+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="lizard"/><category scheme="http://www.blogger.com/atom/ns#" term="paper"/><category scheme="http://www.blogger.com/atom/ns#" term="programando juegos"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="rock"/><category scheme="http://www.blogger.com/atom/ns#" term="scissors"/><category scheme="http://www.blogger.com/atom/ns#" term="Spock"/><title type='text'>rock Spock paper lizard scissors en phyton básico</title><content type='html'>En una ocasión os mencioné coursera, y coursera consigue que haga este código muy básico de python. ¿Conocéis el juego de The Big Bang Theory? Os dejo un video muy ilustrativo:&lt;br/&gt;
&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/jx_EnBk-2rA&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;br/&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
Una imagen para tener delante las relaciones del juego, y aquí el código acorde a la última versión de python ^^
&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEElw5S_aXm24EPaAKVUVvs_nLSl0qIV36J60huJRfBnh6T6hF166kPw602x0t3ZUQYSBOfGJN7HnUxRZL24DaEaY0fOG76yQTFrDFEDqzoyQejnaiznjACDEkxXNWyiafVI8TT70JY7cQ/s1600/rock+paper+scissors+lizard+spock.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEElw5S_aXm24EPaAKVUVvs_nLSl0qIV36J60huJRfBnh6T6hF166kPw602x0t3ZUQYSBOfGJN7HnUxRZL24DaEaY0fOG76yQTFrDFEDqzoyQejnaiznjACDEkxXNWyiafVI8TT70JY7cQ/s320/rock+paper+scissors+lizard+spock.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;

&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
juego.py: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:python&quot;&gt;
# Rock-paper-scissors-lizard-Spock template

# The key idea of this program is to equate the strings
# &quot;rock&quot;, &quot;paper&quot;, &quot;scissors&quot;, &quot;lizard&quot;, &quot;Spock&quot; to numbers
# as follows:
#
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors


#import the library for random numbers
import random

# Convert the number to the correspond number
def number_to_name(number):
    #mod five to avoid wrong numbers
    number=number%5
    if number==0 :
        result=&quot;rock&quot;
    elif number==1:
        result=&quot;Spock&quot;
    elif number==2:
        result=&quot;paper&quot;
    elif number==3:
        result=&quot;lizard&quot;
    else:
        result=&quot;scissors&quot;
    
    return result;

#convert the name to number
def name_to_number(name):
    result=None
    if name==&quot;rock&quot;:
        result=0
    elif name==&quot;Spock&quot;:
        result=1
    elif name==&quot;paper&quot;:
        result=2
    elif name==&quot;lizard&quot;:
        result=3
    elif name==&quot;scissors&quot;:
        result=4
    else:
        print(&quot;Wrong name!! The options are: &quot;)
        print(&quot;rock,Spock,paper,lizard,scissors&quot;)
        print(&quot;&quot;)
        result=-1 # return a negative number for error
    
    return result;

#game
def rpsls(name): 
    # convert name to player_number using name_to_number
    player_number=name_to_number(name)
    
    #check first if I have no errors
    if player_number &gt;=0 :
        # compute random 
        computer_number=random.randrange(0,5)

        # compute difference of player_number and comp_number modulo five
        result_game=(player_number-computer_number)%5
        # use if/elif/else to determine winner
        if result_game==0:
            who_wins=&quot;Player and computer tie!&quot;
        elif result_game &gt; 2:
            who_wins =&quot;Computer wins!&quot;
        else :
            who_wins=&quot;Player wins!&quot;
        
        # convert comp_number to name using number_to_name
        name_computer=number_to_name(computer_number)
        # print results
        print(&quot;Player chooses &quot; + name)
        print(&quot;Computer chooses &quot;+name_computer)
        print (who_wins)
        print
    
# test your code
rpsls(&quot;rock&quot;)
rpsls(&quot;Spock&quot;)
rpsls(&quot;paper&quot;)
rpsls(&quot;lizard&quot;)
rpsls(&quot;scissors&quot;)
#test any error
rpsls(&quot;wrong name&quot;)
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/386260206170558453/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/rock-spock-paper-lizard-scissors-en.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/386260206170558453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/386260206170558453'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/rock-spock-paper-lizard-scissors-en.html' title='rock Spock paper lizard scissors en phyton básico'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEElw5S_aXm24EPaAKVUVvs_nLSl0qIV36J60huJRfBnh6T6hF166kPw602x0t3ZUQYSBOfGJN7HnUxRZL24DaEaY0fOG76yQTFrDFEDqzoyQejnaiznjACDEkxXNWyiafVI8TT70JY7cQ/s72-c/rock+paper+scissors+lizard+spock.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-5060697118738333043</id><published>2013-10-25T23:28:00.000+02:00</published><updated>2013-10-25T23:28:07.435+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="joystick"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><title type='text'>Código Joysticks con SDL</title><content type='html'>Os traigo dos ejemplos de código con joysticks. ¡Me lo he pasado como un niño pequeño!&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMrpWqpoO6Bto2Fm6qPHnhp6zkW35T4qjZKECBuGQTEyeBbEEM52KyM97Edjr7Zsjwfr1q_tuYdRhOirpKYE41yCqIMGrZ7JdkxIFsxTKre0HTPD39ufo5pE24KAE07kXPS4Y2PFDKou7D/s1600/favicon.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMrpWqpoO6Bto2Fm6qPHnhp6zkW35T4qjZKECBuGQTEyeBbEEM52KyM97Edjr7Zsjwfr1q_tuYdRhOirpKYE41yCqIMGrZ7JdkxIFsxTKre0HTPD39ufo5pE24KAE07kXPS4Y2PFDKou7D/s320/favicon.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
El primer código simplemente lista los joystick conectados y algunos detalles, mientras que el segundo mueve un personaje (imagen) por la pantalla. Es una chorrada, ¡pero cómo me lo he pasado! Diez minutos moviendo el joystick como un imbécil viendo cómo se movía el personaje al mismo tiempo.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;


&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Información joysticks: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
// Programa de pruebas. Información acerca del joystick
// Abriendo un dispositivo


#include &amp;ltiostream&amp;gt
#include &amp;ltSDL/SDL.h&amp;gt

using namespace std;
int main(){
 // Iniciamos el subsistema de video
 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) &lt; 0) {
  cerr &lt;&lt; &quot;No se pudo iniciar SDL: %s\n&quot; &lt;&lt; SDL_GetError();
  exit(1);
 }
 atexit(SDL_Quit);
 
 // Comprobamos que sea compatible el modo de video
 if (SDL_VideoModeOK(640, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF) == 0) {
  cerr &lt;&lt; &quot;Modo no soportado: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 // Consultamos el número de joysticks existentes
 int num_joysticks = SDL_NumJoysticks();
 
 // Si no hay joysticks conectados
 if (num_joysticks &lt; 1) {
  cerr &lt;&lt; &quot;Conecte un dispositivo de juego antes de ejecutar&quot; &lt;&lt; endl;
  exit(1);
 } else {
  // Al menos hay uno
  cout &lt;&lt; &quot;Hay conectados &quot; &lt;&lt; num_joysticks &lt;&lt; &quot; joysticks. &quot; &lt;&lt; endl;
 }
 
 // Mostramos información de cada uno de los joysticks
 for ( int i = 0; i &lt; num_joysticks; i++) {
  // Obtenemos el nombre del joystick
  const char *nombre = SDL_JoystickName(i);
  // Lo abrimos
  SDL_Joystick *joy = SDL_JoystickOpen(i);
  // Mostramos en pantalla toda la información
  // disponible del joystick
  cout &lt;&lt; &quot;Abrimos el joystick &quot; &lt;&lt; nombre &lt;&lt; &quot; - &quot; &lt;&lt; i &lt;&lt; endl;
  cout &lt;&lt; &quot;\tTiene &quot; &lt;&lt; SDL_JoystickNumAxes(joy) &lt;&lt; &quot; ejes&quot; &lt;&lt; endl;
  cout &lt;&lt; &quot;\tTiene &quot; &lt;&lt; SDL_JoystickNumButtons(joy) &lt;&lt; &quot; botones&quot; &lt;&lt; endl;
  // Cerramos el joystick
  SDL_JoystickClose(joy);
 }
 return 0;
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code2&#39;,this);&quot;&gt;
Manejo Joysticks: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code2&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
// Programa de pruebas. Joystick captura de movimientos
// Consultando el estado del joystick directamente

#include &amp;ltiostream&amp;gt
#include &amp;ltSDL/SDL.h&amp;gt
using namespace std;

int main() {

 // Iniciamos el subsistema de video
 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) &lt; 0) {
  cerr &lt;&lt; &quot;No se pudo iniciar SDL: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }


 atexit(SDL_Quit);

 // Comprobamos que sea compatible el modo de video
 if (SDL_VideoModeOK(640, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF) == 0) {
  cerr &lt;&lt; &quot;Modo no soportado: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }


 // Establecemos el modo de video
 SDL_Surface *pantalla;
 pantalla = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF);

 if (pantalla == NULL) {
  cerr &lt;&lt; &quot;No se pudo establecer el modo de video: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 // Cargamos una imagen en una superficie
 SDL_Surface *personaje = SDL_LoadBMP(&quot;Imagenes/personaje.bmp&quot;);
 if (personaje == NULL) {
  cerr &lt;&lt; &quot;No se pudo cargar la imagen: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 // Establecemos el color de la transparencia
 // No será mostrado al realizar el blitting
 SDL_SetColorKey(personaje, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(personaje-&gt;format, 255, 255, 255));
 // Posición inicial del personaje
 SDL_Rect posicion;
 posicion.x=300;
 posicion.y=200;
 posicion.w=personaje-&gt;w;
 posicion.h=personaje-&gt;h;
 
 // Copiamos la imagen en la superficie principal
 SDL_BlitSurface(personaje, NULL, pantalla, &amp;posicion);
 // Mostramos la pantalla &quot;oculta&quot; del búffer
 SDL_Flip(pantalla);
 // Si hay un joystick conectado lo abrimos
 SDL_Joystick *joy;
 if (SDL_NumJoysticks() &gt; 0) {
  joy = SDL_JoystickOpen(0);
  cout &lt;&lt; &quot;\nAbrimos el joystick &quot; &lt;&lt; SDL_JoystickName(0) &lt;&lt; &quot; para la prueba. &quot; &lt;&lt; endl;
 } else {
  cout &lt;&lt; &quot;Para llevar acabo esta prueba debe haber un joystick &quot; &lt;&lt; &quot;conectado. Si es así compruebe su configuración&quot; &lt;&lt; endl;
  exit(1);
 }
 
 // Mostramos información del dispositivo
 int num_ejes = SDL_JoystickNumAxes(joy);
 int num_botones = SDL_JoystickNumButtons(joy);
 cout &lt;&lt; &quot;Este joystick tiene &quot; &lt;&lt; num_ejes &lt;&lt; &quot; ejes y &quot; &lt;&lt; num_botones &lt;&lt; &quot; botones.&quot; &lt;&lt; endl;
 cout &lt;&lt; &quot;\nPulse ESC para salir.\n&quot; &lt;&lt; endl;
 // Variable auxiliar
 SDL_Event evento;
 for ( ; ; ) {
  // Actualizamos el estado del joystick
  SDL_JoystickUpdate();
  // Recorremos todos los ejes en búsqueda de cambios de estado
  for ( int i = 0; i &lt; num_ejes; i++) {
   int valor_eje = SDL_JoystickGetAxis(joy, i);
   //cout &lt;&lt; &quot;Eje &quot; &lt;&lt; i &lt;&lt; &quot; -&gt; &quot; &lt;&lt; valor_eje &lt;&lt; endl;
   if (valor_eje != 0) {
    if (i == 0) {
     if (valor_eje &gt; 0)
      posicion.x++;
     if (valor_eje &lt; 0)
      posicion.x--;
    } else {
     if (valor_eje &gt; 0)
      posicion.y++;
     if (valor_eje &lt; 0)
      posicion.y--;
    }
   }
  }
  
  // Limpiamos la pantalla
  SDL_FillRect(pantalla, NULL, 0);
  // Cambiamos la posición del personaje
  SDL_BlitSurface(personaje, NULL, pantalla, &amp;posicion);
  // Actualizamos la pantalla principal
  SDL_Flip(pantalla);
  // Recorremos todos los botones en búsqueda acciones
  for ( int i = 0; i &lt; num_botones; i++) {
   int pulsado = SDL_JoystickGetButton(joy, i);
   if (pulsado) {
    cout &lt;&lt; &quot;Ha pulsado el botón &quot; &lt;&lt; i &lt;&lt; endl;
   }
  }
  // Bucle que controla eventos de salida
  while (SDL_PollEvent(&amp;evento)) {
   if (evento.type == SDL_KEYDOWN) {
    if (evento.key.keysym.sym == SDLK_ESCAPE) {
     SDL_JoystickClose(joy);
     return 0;
    }
   }
 
   if (evento.type == SDL_QUIT) {
    SDL_JoystickClose(joy);
    return 0;
   }
  }
 }
}
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/5060697118738333043/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigo-joysticks-con-sdl.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5060697118738333043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/5060697118738333043'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigo-joysticks-con-sdl.html' title='Código Joysticks con SDL'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMrpWqpoO6Bto2Fm6qPHnhp6zkW35T4qjZKECBuGQTEyeBbEEM52KyM97Edjr7Zsjwfr1q_tuYdRhOirpKYE41yCqIMGrZ7JdkxIFsxTKre0HTPD39ufo5pE24KAE07kXPS4Y2PFDKou7D/s72-c/favicon.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-7323984340294151133</id><published>2013-10-25T23:27:00.003+02:00</published><updated>2013-10-25T23:27:59.449+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="joystick"/><category scheme="http://www.blogger.com/atom/ns#" term="Material de teoría"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><title type='text'>Desarrollo de videojuegos en SDL VII - Joystick</title><content type='html'>&lt;b&gt;Joystick&lt;/b&gt;&lt;br/&gt;
SDL le dedica un subsistema sólo para ello, pero no es le más completo debido a que hay muchos y no siguen un estándar.&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0XhjM4L_KpJKtl4wc9Kr5MgGKZO1YW1CNo-z3deY94_zjQRMaldS2ySYELV5FTelCD7IrtVN4QOLBVdUQ14Y4ZIOC25EIUUU-4LlmW3Pt94nG2DwZE2NDWubHRTkr84IEqr4HZMuQY4Wy/s1600/volante.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0XhjM4L_KpJKtl4wc9Kr5MgGKZO1YW1CNo-z3deY94_zjQRMaldS2ySYELV5FTelCD7IrtVN4QOLBVdUQ14Y4ZIOC25EIUUU-4LlmW3Pt94nG2DwZE2NDWubHRTkr84IEqr4HZMuQY4Wy/s320/volante.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;
Gestión mediante eventos&lt;br/&gt;
Los ejes de movimiento del joystick producen el evento de tipo SDL_JoyAxisEvent:
&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 type; // al mover el eje produce SDL_JOYAXISMOTION&lt;br/&gt;
Uint8 which; //que joystick&lt;br/&gt;
Uint8 axis; //que eje&lt;br/&gt;
Sint16 value; //valor del movimiento&lt;br/&gt;
} SDL_JoyAxisEvent;
&lt;/blockquote&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;
El valor del movimiento depende de si es un eje gradual o analógico (-32768,32768) o un eje digital o determinista (mínimo, cero, máximo).&lt;br/&gt;&lt;br/&gt;

En el caso de los botones producen:
&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 type; // SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP&lt;br/&gt;
Uint8 which; //que joystick&lt;br/&gt;
Uint8 button; //que botón&lt;br/&gt;
Uint8 state; //redundante: SDL_PRESSED, SDL_RELEASED&lt;br/&gt;
} SDL_JoyButtonEvent;
&lt;/blockquote&gt;
&lt;br/&gt;
&lt;b&gt;Inicialización del joystick&lt;/b&gt;
&lt;br/&gt;
Tenemos que inicial el subsistema del joystick al inicio con SDL_Init, pasańdole la constante SDL_INIT_JOYSTICK, para posteriormente abrir el joystick. Tener en cuenta que los index empiezan en cero.
&lt;blockquote&gt;SDL_Joystick* SDL_JoystickOpen(int index);&lt;/blockquote&gt;
&lt;br/&gt;
Cerrar el joystick
&lt;blockquote&gt;void SDL_JoystickClose(SDL_Joystick *joystick);&lt;/blockquote&gt;
&lt;br/&gt;
Que joysticks están abiertos:
&lt;blockquote&gt;int SDL_JoystickOpened(int index);&lt;/blockquote&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Eventos menos usados&lt;/b&gt; en Joysticks corresponden a los minijoystick o hat, el cual tiene 9 posiciones.&lt;br/&gt;
&lt;blockquote&gt;typedef struct{&lt;br/&gt;
Uint8 type;&lt;br/&gt;
Uint8 which; &lt;br/&gt;
Uint8 hat;&lt;br/&gt;
Uint8 value;&lt;br/&gt;
}SDL_JoyHatEvent&lt;/blockquote&gt;
&lt;br/&gt;
Las nueve posiciones de las que dispone se determinan con 5 constantes:
&lt;ul&gt;
&lt;li&gt;SDL_HAT_CENTERED&lt;/li&gt;
&lt;li&gt;SDL_HAT_UP&lt;/li&gt;
&lt;li&gt;SDL_HAT_RIGHT&lt;/li&gt;
&lt;li&gt;SDL_HAT_LEFT&lt;/li&gt;
&lt;li&gt;SDL_HAT_DOWN&lt;/li&gt;
&lt;/ul&gt;
Si no queremos hacer combinaciones con OR, tenemos las siguientes constantes:
&lt;ul&gt;
&lt;li&gt;SDL_HAT_RIGHTUP&lt;/li&gt;
&lt;li&gt;SDL_HAT_RIGHTDOWN&lt;/li&gt;
&lt;li&gt;SDL_HAT_LEFTUP&lt;/li&gt;
&lt;li&gt;SDL_HAT_LEFTDOWN&lt;/li&gt;
&lt;/ul&gt;
&lt;br/&gt;
&lt;b&gt;Otro elemento menos usado&lt;/b&gt; todavía es el trackball, su evento sólo es válido cuando no está integrado en un ratón o teclado.
&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 type;&lt;br/&gt;
Uint8 which;&lt;br/&gt;
Uint8 ball; //SDL presupone que puede haber varios en un joystick&lt;br/&gt;
Sint16 xrel, yrel;&lt;br/&gt;
}SDL_JoyBallEvent;
&lt;/blockquote&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;b&gt;Acceso directo al Joystick&lt;/b&gt;&lt;br/&gt;
Además de consultar el estado del joystick, podemos saber sus características (botones y ejes).&lt;br/&gt;&lt;br/&gt;
Número de joysticks
&lt;blockquote&gt;int SDL_NumJoysticks(void);&lt;/blockquote&gt;
&lt;br/&gt;
Nombre del Joystick
&lt;blockquote&gt;const char *SDL_JoystickName(int index);&lt;/blockquote&gt;
&lt;br/&gt;
Número de ejes
&lt;blockquote&gt;int SDL_JoysticksNumAxes(SDL_Joystick *joystick);&lt;/blockquote&gt;
&lt;br/&gt;
Número de botones
&lt;blockquote&gt;int SDL_JoysticksNumButtons(SDL_Joystick *joystick);&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/7323984340294151133/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-vii.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7323984340294151133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7323984340294151133'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-vii.html' title='Desarrollo de videojuegos en SDL VII - Joystick'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0XhjM4L_KpJKtl4wc9Kr5MgGKZO1YW1CNo-z3deY94_zjQRMaldS2ySYELV5FTelCD7IrtVN4QOLBVdUQ14Y4ZIOC25EIUUU-4LlmW3Pt94nG2DwZE2NDWubHRTkr84IEqr4HZMuQY4Wy/s72-c/volante.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-2701659612056982039</id><published>2013-10-25T23:27:00.001+02:00</published><updated>2013-10-25T23:27:17.319+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eventos"/><category scheme="http://www.blogger.com/atom/ns#" term="Material de teoría"/><category scheme="http://www.blogger.com/atom/ns#" term="ratón"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><title type='text'>Desarrollo de videojuegos en SDL VI - Ratón</title><content type='html'>Llegados hasta aquí, me gustaría recordar que nada de esto es mi autoría y viene del &lt;a href=&quot;http://www.uca.es/softwarelibre/contenidos/tutorialWikiLibSDL-20080131.pdf&quot;&gt;Tutorial de libSDL para la programación de videojuegos&lt;/a&gt;. Tampoco está escrito a modo de divulgación, sino a modo de constancia de lo aprendido en mi viaje y, por tanto, hasta para mi opinión, es un poco desastre las entradas escritas hasta ahora.&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivIzgNp9AaiArp960gpK9lumVdKuLHzm9j1pwd8HK-8XPAxibvCKvRzPLybqmHXNP1_OVpA3HNf2mytl-O1QtT1juaeXuXtYVIEUHa6BHPYrFhikEhbVky4zwawh8c6mJy_rNJaXbVpj24/s1600/mouse-cursor-hand-pointer.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivIzgNp9AaiArp960gpK9lumVdKuLHzm9j1pwd8HK-8XPAxibvCKvRzPLybqmHXNP1_OVpA3HNf2mytl-O1QtT1juaeXuXtYVIEUHa6BHPYrFhikEhbVky4zwawh8c6mJy_rNJaXbVpj24/s320/mouse-cursor-hand-pointer.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;

&lt;b&gt;Ratón&lt;/b&gt;&lt;br/&gt;
Tiene dos tipos de eventos&lt;br/&gt;
De movimiento: contiene la posición del puntero, posición relativa respecto al anterior movimiento y si hay botón pulsado y cuál.&lt;br/&gt;
De pulsación: muy similar al de teclado.&lt;br/&gt;&lt;br/&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 type; // SDL_MOUSEMOTION&lt;br/&gt;
Uint8 state;&lt;br/&gt;
Uint16 x,y;&lt;br/&gt;
Uint16 xrel, yrel; //posición relativa&lt;br/&gt;
} SDL_MouseMotionEvent&lt;/blockquote&gt;
&lt;br/&gt;
state: este campo contiene los flags de los botones. Puede ser consultado con SDL_BUTTON() pasándole 1, 2 ó 3 para preguntar por dicho botón. (1= botón izquierdo, 2=botón central, 3=botón derecho).
&lt;br/&gt;&lt;br/&gt;
También tenemos las constantes SDL_BUTTON_LMASK,SDL_BUTTON_MMASK Y SDL_BUTTON_RMASK.&lt;br/&gt;&lt;br/&gt;

&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 type; //SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP&lt;br/&gt;
Uint8 button; // SDL_BUTTON_LEFT, SDL_BUTTON_RIGHT, SDL_BUTTON_MIDDLE&lt;br/&gt;
Uint8 state; //información redundante SDL_PRESSED, SDL_RELEASED&lt;br/&gt;
Uint16 x,y;&lt;br/&gt;
} SDL_MouseButtonEvent;
&lt;/blockquote&gt;
&lt;br/&gt;

Para consultar el estado del ratón tenemos:
&lt;blockquote&gt;
Uint8 SDL_GetMouseState(int *x, int *y);&lt;br/&gt;
Uint8 SDL_GetRelativeMouseState(int *x, int *y);
&lt;/blockquote&gt;
&lt;br/&gt;

Podemos cambiar la apariencia del cursor teniendo en cuenta la estructura del cursor
&lt;blockquote&gt;
struct{&lt;br/&gt;
SDL_Rect area; //rectángulo que define el área del cursor&lt;br/&gt;
Sint16 hot_x, hot_y; //punto de acción del cursor&lt;br/&gt;
Uint8 *data; //datos de pixel del cursor en blanco y negro&lt;br/&gt;
Uint8 *mask; //máscara del cursor en blanco y negro&lt;br/&gt;
Uint8 *save[2]; //lugar donde se almacenará el cursor&lt;br/&gt;
WMCursor *wm_cursor; //puntero al cursor del gestor de ventanas&lt;br/&gt;
}SDL_Cursor&lt;/blockquote&gt;
&lt;br/&gt;

Crear el cursor:
&lt;blockquote&gt;SDL_Cursor *SDL_CreateCursor(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);&lt;/blockquote&gt;
El ancho debe ser múltiplo de ocho.&lt;br/&gt;
Data y mask son dos imágenes monocromáticas que se combinan. Los tamaños cumplen: vectorSize= h * w/8. Ejemplo: para almacenar un cursor de 32x32 se necesita 32 x 4 bytes.&lt;br/&gt;
Las combinaciones dan:&lt;br/&gt;
Data+Mask=resultado
0+0=transparente&lt;br/&gt;
0+1=blanco&lt;br/&gt;
1+0=color invertido si se puede, si no, negro&lt;br/&gt;
1+1=negro&lt;br/&gt;&lt;br/&gt;

Para setear el cursor:
&lt;blockquote&gt;void SDL_SetCursor(SDL_Cursor *cursor);&lt;/blockquote&gt;
&lt;br/&gt;

Si queremos guardar el anterior cursor:
&lt;blockquote&gt;SDL_Cursor *SDL_GetCursor(void);&lt;/blockquote&gt;&lt;br/&gt;

Para liberarlo:
&lt;blockquote&gt;void SDL_FreeCursor(SDL_Cursor *cursor);&lt;/blockquote&gt;&lt;br/&gt;

Si queremos colocar el cursor en un determinado sitio tenemos:
&lt;blockquote&gt;void SDL_WarpMouse(Uint16 x, Uint16 y);&lt;/blockquote&gt;&lt;br/&gt;

Para mostrar/ocultar el cursor:
&lt;blockquote&gt;int SDL_ShowCursor(int toggle);&lt;/blockquote&gt;
El cual devuelve el estado anterior. Los valores son:
&lt;ul&gt;&lt;li&gt;cero: oculto&lt;/li&gt;
&lt;li&gt;uno:visible&lt;/li&gt;
&lt;/ul&gt;&lt;br/&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/2701659612056982039/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-vi.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2701659612056982039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2701659612056982039'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-vi.html' title='Desarrollo de videojuegos en SDL VI - Ratón'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivIzgNp9AaiArp960gpK9lumVdKuLHzm9j1pwd8HK-8XPAxibvCKvRzPLybqmHXNP1_OVpA3HNf2mytl-O1QtT1juaeXuXtYVIEUHa6BHPYrFhikEhbVky4zwawh8c6mJy_rNJaXbVpj24/s72-c/mouse-cursor-hand-pointer.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-7152156449255453681</id><published>2013-10-25T23:27:00.000+02:00</published><updated>2013-10-25T23:27:08.847+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 82</title><content type='html'>Hoy ya he podido organizar mejor mi tiempo y vengo con bastantes cosas que había hecho en días anteriores y no había escrito. Y todavía me quedan varias cosas por escribir, que dejaré para el próximo día.&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEU04Rv0d2wCtC29rNvmwIDcPsRHuhwUj2WbWAZIvmtkl1SFxF8qUbj4_1j2jo2of3KNeWLNX8vX-VnBuymdy5GejlXBwZBmPpntGX5zKTZpYSn6Y-mlt-l1Xj9HgXEhv0-LEEbVfz4kHO/s1600/viaje.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEU04Rv0d2wCtC29rNvmwIDcPsRHuhwUj2WbWAZIvmtkl1SFxF8qUbj4_1j2jo2of3KNeWLNX8vX-VnBuymdy5GejlXBwZBmPpntGX5zKTZpYSn6Y-mlt-l1Xj9HgXEhv0-LEEbVfz4kHO/s320/viaje.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;
Hoy ha sido un buen día, no lo he dedicado mucho a recorrer mi camino, pero si ha sido aprovechado para otras cosas de las que os hablaré en otra entrada.&lt;br/&gt;
&lt;br/&gt;
Pero de lo que sí hablaré, es que del tutorial que llevo tanto tiempo con él y que es prácticamente todo lo que escribo aquí, he llegado a la parte de los eventos con los joystick, y casualidad de la vida, mi compañero de piso tiene un joystick que tomé prestado para probar.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;

&lt;br/&gt;&lt;br/&gt;
Tendría que haberme grabado para ver la ilusión con la que manejaba el joystick para simplemente mover una imagen por la pantalla. Me recordó a los niños que con poca cosa se ilusionaban, véase, unas canicas, una peonza, una pistolita de juguete... ¡ya ni te cuento si tenían una consola con un juego!&lt;br/&gt;&lt;br/&gt;

Lo que me lleva a recordar mi primera consola. Creo que no llegué a contaros cómo cogí la mochila e inicié este viaje tan... tan... perdido e ingenuo. Los mundos del videojuego son mucho más grandes de lo que pensaba aunque a veces al mismo tiempo parezca tan pequeño.&lt;br/&gt;&lt;br/&gt;
Algún día os contaré la historia si no la conté ya. Volviendo al día (o mejor dicho, a todos los días anteriores que no conté), he retomado un poco la playstation 2 y jugando a uno de los juegos que más me inspiran, Metal Gear Solid (ahora estoy jugando al 2). Eso si, poco a poco, que tengo que racionar mi tiempo.&lt;br/&gt;&lt;br/&gt;
Y en parte ha pasado porque otra vez, mi querido Deimos ha caido más enfermo que antes, y esta vez no tengo seguro médico que me cubra. Me toca pelear más que antes por conseguir darle de nuevo vida aunque mucho me temo que esta vez la solución tendrá que ser radical.&lt;br/&gt;&lt;br/&gt;

Al menos Lyria sigue conmigo. Pero estoy viendo que le estoy dando mucha carga, además de la que le corresponde llevar, está llevando mucho del peso de Deimos y no tiene tanta potencia. Ya hasta la universidad se empieza a resentir con la ausencia de Deimos.
&lt;br/&gt;&lt;br/&gt;
Pero bueno, espero poder resolver pronto el problema, mientras tanto, ¡ahora a la dulce camita! Que ya hay sueño y mucho que hacer mañana.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/7152156449255453681/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/dia-82.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7152156449255453681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7152156449255453681'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/dia-82.html' title='Día 82'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEU04Rv0d2wCtC29rNvmwIDcPsRHuhwUj2WbWAZIvmtkl1SFxF8qUbj4_1j2jo2of3KNeWLNX8vX-VnBuymdy5GejlXBwZBmPpntGX5zKTZpYSn6Y-mlt-l1Xj9HgXEhv0-LEEbVfz4kHO/s72-c/viaje.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-7185706310610551099</id><published>2013-10-24T23:55:00.001+02:00</published><updated>2013-10-24T23:55:27.221+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Humor"/><category scheme="http://www.blogger.com/atom/ns#" term="sinergia sin control"/><category scheme="http://www.blogger.com/atom/ns#" term="trabajo"/><title type='text'>Sinergia sin control</title><content type='html'>Amenizando un poco mi vida, leo cómics, tanto en papel como en web, y uno de los que suelo leer es &lt;a href=&quot;http://sinergiasincontrol.blogspot.com.es/&quot;&gt;Sinergia sin control&lt;/a&gt;, con el que suelo identificarme (y como yo, seguro muchos informáticos) y otras en las que no me identifico pero seguro no tardará en tocarme...
&lt;br/&gt;&lt;br/&gt; Eso si, humor a raudales!! Aquí una prueba que no es de las más divertidas ni de las mejores que tiene, pero que me parece buenísima.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgixBRrbj7OfHftHBF3lsVu13baYIj0N1MVlbjUMkhYtf8PxvXZHedoPz3pCv6uC3zUvc-hKMpzh8QeYO9uya8kMmKjTV1yxyvI1lu2ockX-tUB34VCZ5RfO8vKLpzyWAQekZqIfBCew6WU/s1600/informatico+trabajando.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgixBRrbj7OfHftHBF3lsVu13baYIj0N1MVlbjUMkhYtf8PxvXZHedoPz3pCv6uC3zUvc-hKMpzh8QeYO9uya8kMmKjTV1yxyvI1lu2ockX-tUB34VCZ5RfO8vKLpzyWAQekZqIfBCew6WU/s1600/informatico+trabajando.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/7185706310610551099/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/sinergia-sin-control.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7185706310610551099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/7185706310610551099'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/sinergia-sin-control.html' title='Sinergia sin control'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgixBRrbj7OfHftHBF3lsVu13baYIj0N1MVlbjUMkhYtf8PxvXZHedoPz3pCv6uC3zUvc-hKMpzh8QeYO9uya8kMmKjTV1yxyvI1lu2ockX-tUB34VCZ5RfO8vKLpzyWAQekZqIfBCew6WU/s72-c/informatico+trabajando.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-2879369991007135949</id><published>2013-10-24T23:55:00.000+02:00</published><updated>2013-10-24T23:57:16.935+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="eventos"/><category scheme="http://www.blogger.com/atom/ns#" term="ratón"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><category scheme="http://www.blogger.com/atom/ns#" term="teclado"/><title type='text'>Códigos SDL - eventos básicos teclado y ratón</title><content type='html'>Unos pocos códigos para estudiar y ver su funcionamiento, &lt;s&gt;copiados&lt;/s&gt; basados en el tutorial con el que llevamos estos días.&lt;br/&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFpitXdGqnZKqyXfd_qeBBXDlDOI90Hcf5VCoe1pTxq3aSU32ml1ZvbMTNzeZoFUB7npOOYSbzMNCekhTLlyAhstEbTp28GHmC3InJfWWUWHswcqN8-LKbo3XpAbS_1RTdv0aJM01_ZQEA/s1600/mouse-cursor-hand-pointer.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFpitXdGqnZKqyXfd_qeBBXDlDOI90Hcf5VCoe1pTxq3aSU32ml1ZvbMTNzeZoFUB7npOOYSbzMNCekhTLlyAhstEbTp28GHmC3InJfWWUWHswcqN8-LKbo3XpAbS_1RTdv0aJM01_ZQEA/s320/mouse-cursor-hand-pointer.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;
En este caso son eventos de teclado y ratón. Incluyendo un cambio de cursor del ratón, el cual salió muy raro y no sé si es que está mal el código que había en el tutorial o mi ordenador lo ve raro.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;

Este código incluye capturar eventos de teclado, usando las flechas para mover el personaje por la pantalla y activando la repetición de teclas.
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
Repetición de teclas: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
#include &amp;ltSDL/SDL.h&amp;gt
#include &amp;ltiostream&amp;gt

using namespace std;

int main(){
 //genero pantallas
 SDL_Surface *pantalla, *imagen;
 //guardo evento
 SDL_Event evento;
 
 //variable recuadro para la imagen a cargar
 SDL_Rect posicion;
 
 //iniciar SDL
 if(SDL_Init(SDL_INIT_VIDEO)&lt;0){
  cerr &lt;&lt; &quot;No se pudo inicializar SDL: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 //cierre..
 atexit(SDL_Quit);
 
 //comprobar disponibilidad video
 if(SDL_VideoModeOK(640,480,24, SDL_HWSURFACE|SDL_DOUBLEBUF)==0){
  cerr &lt;&lt; &quot;Modo de video no soportado: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 //iniciamos video
 pantalla=SDL_SetVideoMode(640,480,24,SDL_HWSURFACE|SDL_DOUBLEBUF);
 
 //comprobamos errores
 if(pantalla==NULL){
  cerr &lt;&lt; &quot;Error de pantalla: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 //cargamos la imagen
 imagen=SDL_LoadBMP(&quot;barco.bmp&quot;);
 if(imagen==NULL){
  cerr &lt;&lt; &quot;Error cargando imagen: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 //establezco donde copiarlo
 posicion.x=100;
 posicion.y=0;
 posicion.h=imagen-&gt;h;
 posicion.w=imagen-&gt;w;
 
 //copiamos la imagen
 SDL_BlitSurface(imagen, NULL, pantalla, &amp;posicion);
 //mostramos
 SDL_Flip(pantalla);
 //liberamos la imagen
 //SDL_FreeSurface(imagen);


 int repeat = SDL_EnableKeyRepeat(1, SDL_DEFAULT_REPEAT_INTERVAL);
 if (repeat &lt; 0) {
 cerr &lt;&lt; &quot;No se pudo establecer el modo repetición: &quot;&lt;&lt; SDL_GetError() &lt;&lt; endl;
 }else{
  cout &lt;&lt; &quot;activado repeticón de tecla&quot; &lt;&lt; endl;
 }
 
 //movemos la imagen
 while ( true ) { // o bien for( ; ; )
  while (SDL_PollEvent(&amp;evento)) { 
   if (evento.type == SDL_KEYDOWN) {
    switch (evento.key.keysym.sym) {
     case SDLK_UP:
      posicion.y -= 4;
      if (posicion.y &lt; 0)
       posicion.y = 0;
      break ;
     
     case SDLK_DOWN:
      posicion.y += 4;
      if (posicion.y &gt; 480 - posicion.h)
       posicion.y = 480 - posicion.h;
      break ;
    
     case SDLK_RIGHT:
      posicion.x += 4;
      if (posicion.x &gt; 640 - posicion.w)
       posicion.x = 640 -posicion.w;
      break ;
     case SDLK_LEFT:
      posicion.x -= 4;
      if (posicion.x &lt; 0)
       posicion.x = 0;
      break ;
     case SDLK_ESCAPE:
      SDL_FreeSurface(imagen);
      return 0;
     case SDLK_f:     
      SDL_WM_ToggleFullScreen(pantalla);
      break ;
     default :
      cout &lt;&lt; &quot;Ha pulsado otra tecla&quot; &lt;&lt; endl;
    }
   } 
   // Limpiamos la pantalla
   SDL_FillRect(pantalla, NULL, 0);
   // Cambiamos la posición del personaje
   SDL_BlitSurface(imagen, NULL, pantalla, &amp;posicion);
   // Actualizamos la pantalla principal
   SDL_Flip(pantalla);
   if (evento.type == SDL_QUIT) {
    SDL_FreeSurface(imagen);
    return 0;
   }
  }
 }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br/&gt;&lt;br/&gt;
Estos tres códigos van juntos y es el código referente al ratón, en el que se pueden ver por consola las coordenadas del ratón, con click izquierdo se cambia de cursor, click derecho oculta/muestra el cursor y el botón central resetea dejando el cursor por defecto y en el centro.
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code2&#39;,this);&quot;&gt;
cursor.h: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code2&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
// Listado: cursor.h
//
// Funciones para personalizar el cursor mediante una imagen XPM
//

#ifndef _CURSOR_H_
#define _CURSOR_H_

#include &amp;ltSDL/SDL.h&amp;gt

// Tamaño del apuntador o cursor

const int TAMANO = 32;
// Pasamos una matriz con una imagen XPM y nos devuelve
// un cursor que utilizar con SDL
SDL_Cursor *Cursor_personalizado_XPM( const char *matriz[]);

#endif
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code3&#39;,this);&quot;&gt;
cursor.cpp: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code3&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
// Listado: cursor.cpp
//
// Implementación

#include &amp;ltiostream&amp;gt
#include &quot;cursor.h&quot;

SDL_Cursor *Cursor_personalizado_XPM( const char *matriz[]){
 // Variables auxiliares
 int i, fila, col;
 Uint8 data[4 * TAMANO]; // (h * w / 8)
 Uint8 mask[4 * TAMANO];
 //int hot_x, hot_y;
 i = -1;
 // Recorremos toda la matriz
 for ( fila = 0; fila &lt; TAMANO; ++fila ) {
  for ( col = 0; col &lt; TAMANO; ++col ) {
   // Si no es múltiplo de 8, desplazamos
   if ( col % 8 ) {
    data[i] &lt;&lt;= 1;
    mask[i] &lt;&lt;= 1;
   } else {
    ++i;
    data[i] = mask[i] = 0;
   }

   switch (matriz[4 + fila][col]) {
    case &#39;X&#39;:
     data[i] |= 0x01;
     mask[i] |= 0x01;
     break;

    case &#39;.&#39;:
     mask[i] |= 0x01;
     break ;

    case &#39; &#39;:
     break;
   }
  }
 }
 return SDL_CreateCursor(data, mask, TAMANO, TAMANO, 15, 15);
}
&lt;/pre&gt;
&lt;/div&gt;

&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code4&#39;,this);&quot;&gt;
main.cpp: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code4&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
// Listado 6 - Eventos
//
// Listado: main.cpp
// Programa de pruebas. Eventos de ratón. Personalización del cursor
// Este programa prueba diferentes funciones
// referentes al manejo del ratón

#include &amp;ltiostream&amp;gt
#include &amp;ltiomanip&amp;gt

#include &amp;ltSDL/SDL.h&amp;gt
#include &quot;cursor.h&quot;

using namespace std;

int main(){
 // Iniciamos el subsistema de video
 if (SDL_Init(SDL_INIT_VIDEO) &lt; 0) {
  cerr &lt;&lt; &quot;No se pudo iniciar SDL: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }

 atexit(SDL_Quit);

 // Comprobamos que sea compatible el modo de video
 if (SDL_VideoModeOK(640, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF) == 0) {
  cerr &lt;&lt; &quot;Modo no soportado: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }

 // Establecemos el modo de video
 SDL_Surface *pantalla;
 pantalla = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE|SDL_DOUBLEBUF);

 if (pantalla == NULL) {
  cerr &lt;&lt; &quot;No se pudo establecer el modo de video: &quot; &lt;&lt; SDL_GetError() &lt;&lt; endl;
  exit(1);
 }
 
 // Imagen en XPM para personalizar el cursor
 const char *punto_mira[] = {
  // ancho alto num_colors bytes_per_pixel */
  &quot; 32 32 3 1&quot;,
  // definición de los colores
  &quot;. c #000000&quot;
  &quot;X c #ffffff&quot;,
  &quot; c None&quot;,
  
  // píxels
  &quot; &quot;, //1
  &quot; &quot;,
  &quot; &quot;,
  &quot; &quot;,
  &quot; &quot;, //5
  &quot; &quot;,
  &quot; &quot;,
  &quot; XXXXXX &quot;,
  &quot; XXXX X XXXX &quot;,
  &quot; XXX XXX &quot;, //10
  &quot; XX XX &quot;,
  &quot; X X X &quot;,
  &quot; X X X &quot;,
  &quot; X X X &quot;,
  &quot; XX XXXXXXXXXXX XX &quot;, //15
  &quot; X X X &quot;,
  &quot; X X X &quot;,
  &quot; X X X &quot;,
  &quot; X X X &quot;,
  &quot; XX XX &quot;, //20
  &quot; XXX XXX &quot;,
  &quot; XXXX X XXXX &quot;,
  &quot; XXXXXX &quot;,
  &quot; &quot;,
  &quot; &quot;, //25
  &quot; &quot;,
  &quot; &quot;,
  &quot; &quot;,
  &quot; &quot;,
  &quot; &quot;, // 30
  &quot; &quot;,
  &quot; &quot;, // 32
  &quot;0,0&quot;
 };
 
 // Rellenamos la pantalla de un color diferente al negro
 Uint32 color = SDL_MapRGB(pantalla-&gt;format, 25, 100, 155);
 // Sólo en el rango que vamos a permitir para el ratón
 SDL_Rect delimitador;
 delimitador.x=100;
 delimitador.y=100;
 delimitador.w=440;
 delimitador.h=280;
 
 SDL_FillRect(pantalla, &amp;delimitador, color);
 // Actualizamos la pantalla
 SDL_Flip(pantalla);
 // Guardamos el cursor original
 SDL_Cursor *original = SDL_GetCursor();
 
 SDL_Event evento;
 // Bucle &quot;infinito&quot;
 int ocultar=0;
 for ( ; ; ) {
  
  while (SDL_PollEvent(&amp;evento)) {
   if (evento.type == SDL_KEYDOWN) {
    if (evento.key.keysym.sym == SDLK_ESCAPE) {
     SDL_FreeCursor(original);
    }
    return 0;
   }
  
   if (evento.type == SDL_QUIT){
    return 0;
   }
  
   // Movemos el ratón
   if (evento.type == SDL_MOUSEMOTION){
    if (evento.motion.x &gt; 540 || evento.motion.x &lt; 100 ||
     evento.motion.y &gt; 380 || evento.motion.y &lt; 100 ) {
     // Si se sale de este rango
     // Vuelve dentro de él
     cout &lt;&lt; &quot;Te has salido del rectángulo azul&quot; &lt;&lt; endl;
     SDL_WarpMouse(250, 200);
    }
    cout &lt;&lt; &quot;X: &quot; &lt;&lt; setw(3) &lt;&lt; evento.motion.x &lt;&lt; &quot; - Y: &quot; &lt;&lt; setw(3) &lt;&lt; evento.motion.y &lt;&lt; endl;
   }
   
   // Pulsamos un botón del ratón
   if (evento.type == SDL_MOUSEBUTTONDOWN) {
    if (evento.button.button == 1) {
     cout &lt;&lt; &quot;X: &quot; &lt;&lt; setw(3) &lt;&lt; evento.button.x &lt;&lt; &quot; - Y: &quot; &lt;&lt; setw(3) &lt;&lt; evento.button.y
      &lt;&lt; &quot; Botón izquierdo pulsado, cursor personalizado&quot; &lt;&lt; endl;
     // Personalizamos el cursor
     SDL_Cursor *apuntador;
     apuntador = Cursor_personalizado_XPM(punto_mira);
     // Lo establecemos
     SDL_SetCursor(apuntador);
     // Nos aseguramos de que se muestra
     SDL_ShowCursor(1);
    } else if (evento.button.button == 2) {
     // Mostramos el cursor
     SDL_ShowCursor(1);
     // Reestablecemos el original
     SDL_SetCursor(original);
     cout &lt;&lt; &quot;Botón central, vuelta al cursor original&quot; &lt;&lt; endl;
    } else {
     // Ocultamos el cursor
     SDL_ShowCursor(ocultar);
     ocultar=!ocultar;
    }
   }
  }
 }
 cout &lt;&lt; &quot;Botón derecho pulsado, se oculta el cursor&quot; &lt;&lt; endl;
 return 0;
}
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/2879369991007135949/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigos-sdl-eventos-basicos-teclado-y.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2879369991007135949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2879369991007135949'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigos-sdl-eventos-basicos-teclado-y.html' title='Códigos SDL - eventos básicos teclado y ratón'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFpitXdGqnZKqyXfd_qeBBXDlDOI90Hcf5VCoe1pTxq3aSU32ml1ZvbMTNzeZoFUB7npOOYSbzMNCekhTLlyAhstEbTp28GHmC3InJfWWUWHswcqN8-LKbo3XpAbS_1RTdv0aJM01_ZQEA/s72-c/mouse-cursor-hand-pointer.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-2365760412622559765</id><published>2013-10-24T23:54:00.000+02:00</published><updated>2013-10-24T23:56:34.271+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="eventos"/><category scheme="http://www.blogger.com/atom/ns#" term="Material de teoría"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><category scheme="http://www.blogger.com/atom/ns#" term="teclado"/><title type='text'>Desarrollo de videojuegos en SDL V</title><content type='html'>Y nos vamos a los eventos en SDL, de &lt;a href=&quot;http://www.uca.es/softwarelibre/contenidos/tutorialWikiLibSDL-20080131.pdf&quot;&gt;Tutorial de libSDL para la programación de videojuegos&lt;/a&gt;.
&lt;br/&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPKgA6GvUHR0jsghfJWNv7IlNDFlesbQeZd1407f8-zYPVQ3Y00CugcuAe6wFXjJ0xxOyUr1UYQgGjAHL7t20LBBqjneM8Brx10aFQCJ5Y9_avKKslwrhBw-nXMaXbgtt0uxzNhGVHli65/s1600/teclado.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPKgA6GvUHR0jsghfJWNv7IlNDFlesbQeZd1407f8-zYPVQ3Y00CugcuAe6wFXjJ0xxOyUr1UYQgGjAHL7t20LBBqjneM8Brx10aFQCJ5Y9_avKKslwrhBw-nXMaXbgtt0uxzNhGVHli65/s320/teclado.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;
La estructura principal es
&lt;blockquote&gt;
typedef union{&lt;br/&gt;
Uint8 type;&lt;br/&gt;
SDL_ActiveEvent active; //tipo de evento&lt;br/&gt;
SDL_KeyboardEvent key;&lt;br/&gt;
SDL_MouseMotionEvent motion;&lt;br/&gt;
SDL_MouseButtonEvent button;&lt;br/&gt;
SDL_JoyAxisEvent jaxis;&lt;br/&gt;
SDL_JoyBallEvent jball;&lt;br/&gt;
SDL_JoyHatEvent jhat;&lt;br/&gt;
SDL_JoyButtonEvent jbutton;&lt;br/&gt;
SDL_ResizeEvent resize;&lt;br/&gt;
SDL_QuitEvent quit;&lt;br/&gt;
SDL_UserEvent user;&lt;br/&gt;
SDL_SysWMEvent syswm;&lt;br/&gt;
} SDL_Event;
&lt;/blockquote&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br/&gt;

Una breve explicación:
&lt;ul&gt;&lt;li&gt;active: evento de activación. Informa de la situación del foco sobre la ventana.&lt;/li&gt;
&lt;li&gt;key: evento producido por el teclado.&lt;/li&gt;
&lt;li&gt;motion: evento producido por movimiento del ratón.&lt;/li&gt;
&lt;li&gt;button: evento producido por el botón del ratón.&lt;/li&gt;
&lt;li&gt;jaxis: evento de movimiento del eje del joystick.&lt;/li&gt;
&lt;li&gt;jball: evento de movimiento del trackball del joystick.&lt;/li&gt;
&lt;li&gt;jhat: evento de movimiento del minijoystick o hat del dispositivo.&lt;/li&gt;
&lt;li&gt;jbutton: evento por botón del mando.&lt;/li&gt;
&lt;li&gt;resize: evento por redimensionado de ventana.&lt;/li&gt;
&lt;li&gt;quit: evento al cerrar aplicación.&lt;/li&gt;
&lt;li&gt;user: evento definido por el usuario.&lt;/li&gt;
&lt;li&gt;syswm: evento indefinido  producido por el gestor de ventanas.&lt;/li&gt;&lt;/ul&gt;
&lt;br/&gt;
&lt;b&gt;Formas de capturar eventos&lt;/b&gt;&lt;br/&gt;
&lt;b&gt;Waiting&lt;/b&gt;: El programa espera por los eventos que se produzcan. Técnica muy utilizada en sistemas de gestión, donde no hay tareas en segundo plano, pero en juegos es poco útil.
&lt;blockquote&gt;int SDL_WaitEvent(SDL_Event *event);&lt;/blockquote&gt;
&lt;br/&gt;
Cuando se produce un evento, se rellenan los datos de event. Devuelve 1 si se ha copiado correctamente y eliminado de la lista de eventos. Cero al contrario. Si se pasa NULL, devuelve que ha pasado pero sin variar la cola.
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Acceso directo&lt;/b&gt; al estado de eventos del dispositivo: 
Podemos acceder simbólicamente al hardware y leer el estado de un dispositivo discriminando la información con la idea de seleccionar sólo la que es relevante para nosotros. En realidad accedemos al sistema de eventos que es una capa superior a la de hardware que nos presenta la información para que podamos manejarla de forma cómoda.
&lt;br/&gt;&lt;br/&gt;
Con éste método se peuden perder eventos. Cada vez que queramos consultar el estado, debemos actualizar primero con 
&lt;blockquote&gt;void SDL_PumpEvents(void);&lt;/blockquote&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Polling&lt;/b&gt;:Técnica muy común, almacenamos los eventos en una cola para consultar en cualquier momento que deseemos (sondeo). SDL proporciona la cola.&lt;br/&gt;
Básicamente es comprobar si hay eventos, tratarlos si hay e ir haciendo otras tareas. Muy adecuado para videojuegos.
&lt;blockquote&gt;int SDL_PollEvent(SDL_Event *event);&lt;/blockquote&gt;&lt;br/&gt;
Devuelve cero si no hay eventos pendientes, uno al contrario. Si le pasamos NULL, el evento no se elimina de la cola.
&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Teclado&lt;/b&gt;&lt;br/&gt;
El tipo de evento que muestra el teclado es SDL_KEYUP o SDL_KEYDOWN. Dentro de su estructura tiene un campo state, que resulta redundante, con los valores SDL_PRESSED y SDL_RELEASED.
&lt;blockquote&gt;
typedef struct {&lt;br/&gt;
Uint8 type;&lt;br/&gt;
Uint8 state;&lt;br/&gt;
SDL_keysym keysym;&lt;br/&gt;
} SDL_KeyboardEvent;&lt;br/&gt;
&lt;/blockquote&gt;
&lt;br/&gt;
keysym tiene la siguiente estructura:
&lt;blockquote&gt;
typedef struct{&lt;br/&gt;
Uint8 scancode; //desaconsejado ya que depende del teclado y del sistema&lt;br/&gt;
SDL_Key sym; //tecla pulsada. Constantes SDL como SDL_a&lt;br/&gt;
SDLMod mod; //teclas especiales pulsadas (Ctrl, Alt, Shift)&lt;br/&gt;
Unit16 unicode; //por defecto no es rellenado&lt;br/&gt;
} SDL_Keysym;
&lt;/blockquote&gt;
&lt;br/&gt;
Para que el campo unicode se rellene, se activa con:
&lt;blockquote&gt;int SDL_EnableUNICODE(int enable);&lt;/blockquote&gt;
El cual devuelve el estado anterior al cambio.&lt;br/&gt;
0-Desactivado&lt;br/&gt;
1-Activado&lt;br/&gt;
2-sin cambio (para consulta)&lt;br/&gt;&lt;br/&gt;

En algunas aplicaciones es interesante que si pulsamos cierta tecla durante un tiemp, dicha letra oacción se repita varias veces. Para activar esta opción hemos de llamar a :
&lt;blockquote&gt;int SDL_EnableKeyRepeat(int delay, int interval);&lt;/blockquote&gt;&lt;br/&gt;
La función devuelve cero si todo ha ido bien o -1 ante errores.&lt;br/&gt;
delay: tiempo que deve esperar antes de hacer efectiva la repetición.&lt;br/&gt;
interval: cada cuánto tiempo se repite.&lt;br/&gt;&lt;br/&gt;
Para ambos valores, SDL proporciona lo que a su juicio son valores adecuados. Se pueden obtener con las constantes SDL_DEFAULT_REPEAT_DELAY y SDL_DEFAULT_REPEAT_INTERVAL.&lt;br/&gt;&lt;br/&gt;

Si queremos acceder de forma directa al teclado y consultar su estado tenemos la función:
&lt;blockquote&gt;Uint8 *SDL_GetKeyState(int *numkeys);&lt;/blockquote&gt;
&lt;br/&gt; El parámetro que recibe especifica el tamaño del vector que queremos obtener. Es habitual poner NULL como parámetro, lo que produce que la función nos devuelva el valor del estado para todas las teclas. Para consultar en el vector se usan las mismas constantes del campo sym. Si la tecla está pulsada, será 1, cero al contrario.&lt;br/&gt;&lt;br/&gt;
Para conocer el estado de las teclas modificadoras y forzar el estado de alguna de ellas tenemos
&lt;blockquote&gt;SDLMod SDL_GetModState(void);&lt;br/&gt;
void SDL_SetModState(SDLMod modstate);&lt;/blockquote&gt;
&lt;br/&gt;
Y por último, si queremos conocer el nombre de una tecla de forma humana, la siguiente función:
&lt;blockquote&gt;char *SDL_GetKeyName(SDLKey key);&lt;/blockquote&gt;


&lt;br/&gt;&lt;br/&gt;
Y hasta aquí hoy, es mucho. Unos cuantos pensaréis que estoy pasando el tutorial del pdf al blog, y en parte es cierto, ya avisé que esto no iba a ser una especie de clase, sino una especie de apuntes/resumen de lo que leo y aprendo. Y que sepáis que hasta aquí es la página 216 del tutorial, con lo que creo que lo resumo bastante jajaja.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/2365760412622559765/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-v.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2365760412622559765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/2365760412622559765'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/desarrollo-de-videojuegos-en-sdl-v.html' title='Desarrollo de videojuegos en SDL V'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPKgA6GvUHR0jsghfJWNv7IlNDFlesbQeZd1407f8-zYPVQ3Y00CugcuAe6wFXjJ0xxOyUr1UYQgGjAHL7t20LBBqjneM8Brx10aFQCJ5Y9_avKKslwrhBw-nXMaXbgtt0uxzNhGVHli65/s72-c/teclado.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-3153454027661936820</id><published>2013-10-24T23:50:00.002+02:00</published><updated>2013-10-24T23:50:45.667+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Diario del viajero"/><title type='text'>Día 81</title><content type='html'>Ya paso de decir nada sobre mi voluntad, lo que tardo en escribir, que si haré esto, lo otro... Tan solo seguiré. Y seguir, aquí sigo, tratando de repartir mi tiempo entre todo y he avanzado bastante. Hay cosas nuevas, cosas excitantes, buenos avances (dentro de lo que cabe).
&lt;br/&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg83At60mTKheDtnp3r-ErCKxF-u9JG2TcW51-Cdcc-6JVPPkzNOWBlnY5RgIWI1nPg98vkygQbtpw4GDjZayM9xqIcD7hU3-A_u3a2uIxBtkqOIpcD3hhORADLV6ZdKi53oAPNoDBMu_Fw/s1600/mundo_de_zelda-1024x768.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg83At60mTKheDtnp3r-ErCKxF-u9JG2TcW51-Cdcc-6JVPPkzNOWBlnY5RgIWI1nPg98vkygQbtpw4GDjZayM9xqIcD7hU3-A_u3a2uIxBtkqOIpcD3hhORADLV6ZdKi53oAPNoDBMu_Fw/s320/mundo_de_zelda-1024x768.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br/&gt;
Y el hecho de dejar para el final escribir las entradas, lo fastidia todo. Llego tan cansado del viaje que no soy capaz de plasmar aquí lo realmente sucedido en el día e incluso he dejado cosas para publicar mañana. Ya sé que es lo siguiente a cambiar.
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;
Querido diario, no dejes que decaiga, no dejes que desaparezca la culpabilidad ni el malestar por no cumplir mi propia palabra... es ir directo al fracaso y parece como si desarrollar videojuegos no fuera mi sueño.</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/3153454027661936820/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/dia-81.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/3153454027661936820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/3153454027661936820'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/dia-81.html' title='Día 81'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg83At60mTKheDtnp3r-ErCKxF-u9JG2TcW51-Cdcc-6JVPPkzNOWBlnY5RgIWI1nPg98vkygQbtpw4GDjZayM9xqIcD7hU3-A_u3a2uIxBtkqOIpcD3hhORADLV6ZdKi53oAPNoDBMu_Fw/s72-c/mundo_de_zelda-1024x768.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-434935525053944599.post-1317489846154569719</id><published>2013-10-10T23:28:00.002+02:00</published><updated>2013-10-11T19:03:32.463+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bitmaps"/><category scheme="http://www.blogger.com/atom/ns#" term="color key"/><category scheme="http://www.blogger.com/atom/ns#" term="Código fuente"/><category scheme="http://www.blogger.com/atom/ns#" term="imagenes"/><category scheme="http://www.blogger.com/atom/ns#" term="SDL"/><category scheme="http://www.blogger.com/atom/ns#" term="transparencia"/><title type='text'>Código practica - bitmaps con SDL</title><content type='html'>Dos códigos, dos simples mains, uno cargo una imagen bmp en pantalla y el otro más de lo mismo, base para todo videojuego que pueda hacer y que se honre con tal nombre. Hasta ahora no tengo nada que lleve ese nombre.&lt;br/&gt;
Peeero, estos códigos son imprescindibles para mi camino a recorrer. ^^&lt;br/&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLIGXV1JbfZIPeBwo2JkGl2xcyoyy9GuOUfxjGv0SYoxbC3lxQXDzxMr3VR6K1TDBua5VKmLelfYqbo5ovtPnsbDth5JLxL8QWCmz8WyRq7BU6bhS7U70C8mzhtpaX04ItCCAVTMLHymmo/s1600/link2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLIGXV1JbfZIPeBwo2JkGl2xcyoyy9GuOUfxjGv0SYoxbC3lxQXDzxMr3VR6K1TDBua5VKmLelfYqbo5ovtPnsbDth5JLxL8QWCmz8WyRq7BU6bhS7U70C8mzhtpaX04ItCCAVTMLHymmo/s320/link2.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br/&gt;
Lo único a tener en cuenta en el código es la ruta hacia la imagen que se muestra, que debe ser si o si bmp. (Según la definición del método, tampoco he probado).
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code&#39;,this);&quot;&gt;
main.c: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
#include &amp;ltstdio.h&amp;gt
#include &amp;ltSDL/SDL.h&amp;gt

//método auxiliar que uso
SDL_Surface *inicializacion();

int main(){
        //pantallas que uso
 SDL_Surface *pantalla, *imagen;
        //donde dibujaré
 SDL_Rect destino;
 
 //inicializo
 pantalla=inicializacion();
 
 if (pantalla == NULL) {
  printf(&quot;Error iniciando el entorno gráfico: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
        //cargo la imagen
 imagen = SDL_LoadBMP(&quot;images/sasuke.bmp&quot;);
 
 if(imagen==NULL){
  printf(&quot;Error al cargar la imagen: %s\n&quot;, SDL_GetError());
  exit(0);
 }
 
 // Guardamos el BMP con otro nombre
 if (SDL_SaveBMP(imagen, &quot;images/sasuke2.bmp&quot;) == -1){
  printf(&quot;No se puede guardar la imagen\n&quot;);
 }
 
 // Inicializamos la variable de posición y tamaño de destino
 destino.x = 250;
 destino.y = 150; 
 destino.w = imagen-&gt;w;
 destino.h = imagen-&gt;h;
 
 // Copiamos la superficie creada rectángulo en la anterior pantalla
 SDL_BlitSurface(imagen, NULL, pantalla, &amp;destino);

 // Mostramos la pantalla
 SDL_Flip(pantalla);

 // Ya podemos liberar el rectángulo, una vez copiado y mostrado
 SDL_FreeSurface(imagen);

 SDL_Delay(5000);
 exit(0);
}

SDL_Surface *inicializacion(){
 SDL_Surface *pantalla;
 if(SDL_Init(SDL_INIT_VIDEO)&lt;0){
  printf(&quot;No se pudo iniciar SDL: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
 atexit(SDL_Quit);
 
 if(SDL_VideoModeOK(1024,768,24,SDL_SWSURFACE|SDL_DOUBLEBUF)==0){
  printf(&quot;Modo no soportado: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
 //saco la pantalla
 pantalla=SDL_SetVideoMode(1024, 768, 24, SDL_SWSURFACE|SDL_DOUBLEBUF);
 
 if (pantalla == NULL) {
  printf(&quot;Error iniciando el entorno gráfico: %s/n&quot;, SDL_GetError());
  exit(1);
 }
 
 return pantalla;
}&lt;/pre&gt;
&lt;/div&gt;


&lt;br/&gt;
El otro código es el mismo main pero añadiendo el manejo del color key, siendo el magenta el que usé en mi imagen.
&lt;div class=&quot;linkContraido&quot; onclick=&quot;spoiler(&#39;code2&#39;,this);&quot;&gt;
main.c: Pulsa para ver/ocultar el código&lt;/div&gt;
&lt;div class=&quot;elementoOculto&quot; id=&quot;code2&quot;&gt;
&lt;pre class=&quot;brush:cpp&quot;&gt;
#include &lt;stdio.h&gt;
#include &lt;SDL/SDL.h&gt;

SDL_Surface *inicializacion();

int main(){
 SDL_Surface *pantalla, *imagen;
 SDL_Rect destino;
 
 //inicializo
 pantalla=inicializacion();
 
 if (pantalla == NULL) {
  printf(&quot;Error iniciando el entorno gráfico: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
 imagen = SDL_LoadBMP(&quot;images/sasuke.bmp&quot;);
 
 if(imagen==NULL){
  printf(&quot;Error al cargar la imagen: %s\n&quot;, SDL_GetError());
  exit(0);
 }
 
 // Inicializamos la variable de posición y tamaño de destino
 destino.x = 250;
 destino.y = 150; 
 destino.w = imagen-&gt;w;
 destino.h = imagen-&gt;h;
 
 //aplico transparencia
 Uint32 color=SDL_MapRGB(imagen-&gt;format, 255, 0, 255);
 SDL_SetColorKey(imagen, SDL_SRCCOLORKEY|SDL_RLEACCEL, color);
 
 // Copiamos la superficie creada rectángulo en la anterior pantalla
 SDL_BlitSurface(imagen, NULL, pantalla, &amp;destino);

 // Mostramos la pantalla
 SDL_Flip(pantalla);

 // Ya podemos liberar el rectángulo, una vez copiado y mostrado
 SDL_FreeSurface(imagen);

 SDL_Delay(5000);
 exit(0);
}

SDL_Surface *inicializacion(){
 SDL_Surface *pantalla;
 if(SDL_Init(SDL_INIT_VIDEO)&lt;0){
  printf(&quot;No se pudo iniciar SDL: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
 atexit(SDL_Quit);
 
 if(SDL_VideoModeOK(1024,768,24,SDL_HWSURFACE|SDL_DOUBLEBUF)==0){
  printf(&quot;Modo no soportado: %s\n&quot;, SDL_GetError());
  exit(1);
 }
 
 //saco la pantalla
 pantalla=SDL_SetVideoMode(1024, 768, 24, SDL_SWSURFACE|SDL_DOUBLEBUF);
 
 if (pantalla == NULL) {
  printf(&quot;Error iniciando el entorno gráfico: %s/n&quot;, SDL_GetError());
  exit(1);
 }
 
 return pantalla;
}
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mundosdelvideojuego.blogspot.com/feeds/1317489846154569719/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigo-practica-bitmaps-con-sdl.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/1317489846154569719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/434935525053944599/posts/default/1317489846154569719'/><link rel='alternate' type='text/html' href='http://mundosdelvideojuego.blogspot.com/2013/10/codigo-practica-bitmaps-con-sdl.html' title='Código practica - bitmaps con SDL'/><author><name>Dorian Hawkmoon</name><uri>http://www.blogger.com/profile/08758422293688725749</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhHYp7QgW94ddOVv53YIFhZWCqx1FXGlLUZGbbSEf5TYsZqhTYElwABhH177dyV_9fco4QoTtHG7hrsDS5S6XdSQFFT_090ZUXdtIEu_gdS2857_CBciR6_wlRXCK96w/s220/avatarmsn.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLIGXV1JbfZIPeBwo2JkGl2xcyoyy9GuOUfxjGv0SYoxbC3lxQXDzxMr3VR6K1TDBua5VKmLelfYqbo5ovtPnsbDth5JLxL8QWCmz8WyRq7BU6bhS7U70C8mzhtpaX04ItCCAVTMLHymmo/s72-c/link2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>