Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


Publicar nuevo tema  Responder al tema 
Página 1 de 1
 
 
Aprende A Programar Juegos. C++, Python
Autor Mensaje
Responder citando   Descargar mensaje  
Mensaje Aprende A Programar Juegos. C++, Python 
 
Buenas!.

Esto es solamente un enlace a una página para que conozcáis varios libros.
No se pueden bajar, claro.

Los ejemplos parecen los mismos, solo que para los dos lenguajes que he puesto en el tema del mensaje.
Y......también parece que no necesitáis conocimientos previos. Claro que los juegos son para la consola!. Nada de formularios..oooh.

Tenéis:

Beginning C++ Through Game Programming

Citar:

The book has everything you need in order to learn the fundamentals of C++ and text-based game programming basics. No previous programming experience is necessary – the book starts you off right at the beginning. You'll glide through small but complete programs for each new concept, and explore a full game program at the end of each chapter. Finally, you'll be presented with a major game project at the end of the book that brings together all of the essential topics.  


Python Programming for the Absolute Beginner

Citar:

The book is aimed at teaching, well, absolute beginners how to program in Python. However, it takes the unique approach of showing the reader programming concepts through creating simple games. In fact, a full game program is presented at the end of each chapter. And a major game project is tackled in the final chapter. By the end of the book, a total programming newbie will be able to write games with graphics, sound and animation.  


Se habla de ambos en:

ProgramGames

Saludos
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
...y algo en C:  
                                 whistle
http://the3fold.free.fr/doc/games.pdf
 



 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
Vuott:

Muy bueno el pdf. Parece que es para empezar de 0, ¿ no ?.
Es que trae de todo. Por eso me pareció complicado para cualquiera que quiera empezar.

Todas esas páginas y solo 1M8 de tamaño.  

Saludos
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
Shell escribió: [Ver mensaje]
Por eso me pareció complicado para cualquiera que quiera empezar.


...quizás....

Vamos a ver el ejemplo (un po' modificado) de la pagina 98 del pdf, usando las funciones externas del API de SDL:
Public Struct imagen_s
  x As Integer
  y As Integer
  dx As Integer
  dy As Integer
End Struct

Private imagenes[4] As Struct Imagen_s

Public Struct SDL_Rect
  x As Short
  y As Short
  w As Short
  h As Short
End Struct

Private Const SDL_INIT_VIDEO As Integer = 32
Private Const MAX_SPEED As Integer = 6
Private Const RAND_MAX As Integer = 32767
Private screen As Pointer
Private im As Pointer


Library "libSDL-1.2:0.11.4"

' int SDL_Init(Uint32 flags)
' Initializes the SDL library.
Private Extern SDL_Init(flags As Integer) As Integer

' const char* SDL_GetError(void)
' Retrieves a message about the last error that occurred.
Private Extern SDL_GetError() As String

' SDL_Surface* SDL_SetVideoMode(int width, int height, int bitsperpixel, Uint32 flags)
' Sets up a video mode with the specified width, height and bits-per-pixel.
Private Extern SDL_SetVideoMode(width As Integer, height As Integer, bitsperpixel As Integer, flags As Integer) As Pointer

' SDL_RWops * SDL_RWFromFile(const char *file, const char *mode)
' Creates a new SDL_RWops structure for reading from and/or writing to a named file.
Private Extern SDL_RWFromFile($file As String, mode As String) As Pointer

' void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
' Makes sure the given area is updated on the given screen.
Private Extern SDL_UpdateRect(sdlsurface As Pointer, x As Integer, y As Integer, w As Integer, h As Integer)

' int SDL_BlitSurface(SDL_Surface* src, const SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect)
' Performs a fast surface copy to a destination surface.
Private Extern SDL_BlitSurface(src As Pointer, srcrect As SDL_Rect, dst As Pointer, dstrect As SDL_Rect) As Integer

' void SDL_FreeSurface(SDL_Surface* surface)
' Frees an RGB surface.
Private Extern SDL_FreeSurface(surface As Pointer)

' void SDL_Quit(void)
' Cleans up all initialized subsystems.
Private Extern SDL_Quit()


Library "libSDL_image-1.2:0.8.4"

' SDL_Surface * IMG_LoadPNG_RW(SDL_RWops *src)
' Load src as a PNG image for use as a surface.
Private Extern IMG_LoadPNG_RW(src As Pointer) As Pointer

' int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
' Performs rectangle validation.
Private Extern SDL_UpperBlit(src As Pointer, srcrect As SDL_Rect, dst As Pointer, dstrect As SDL_Rect) As Integer


Public Sub Main()

  Dim r, frames As Integer

' Initialize SDL's video system and check for errors:
    r = SDL_Init(SDL_INIT_VIDEO)
    If r <> 0 Then Error.Raise("Impossible inicializar SDL2: " & SDL_GetError())
    
' Attempt to set a 640x480 hicolor (16-bit) video mode:
    screen = SDL_SetVideoMode(640, 480, 16, 0)
    If IsNull(screen) Then Error.Raise("Impossible crear la ventana: " & SDL_GetError())
    
' Carga una imagen pequeña 16x16:
    im = IMG_LoadPNG_RW(SDL_RWFromFile("/usr/share/icons/hicolor/16x16/actions/package-broken.png", "rb"))
    If IsNull(im) Then Error.Raise("Impossible cargar la imagen: " & SDL_GetError())
    
    init_imagenes()
    
' Animate 4000 frames:
    For frames = 1 To 4000
      
' Put the images on the screen:
      draw_imagenes()
      
' Ask SDL to update the entire screen:
      SDL_UpdateRect(screen, 0, 0, 0, 0)
      
' Move the images for the next frame:
      move_imagenes()
      
    Next
    
    
    SDL_FreeSurface(im)
    SDL_Quit()

End


Private Procedure init_imagenes()
  
  Dim i As Integer
  
    For i = 0 To 3
      imagenes[i].x = Rand(0, RAND_MAX) % Int@(screen + 16)
      imagenes[i].y = Rand(0, RAND_MAX) % Int@(screen + 20)
      imagenes[i].dx = (Rand(0, RAND_MAX) % (MAX_SPEED * 2)) - MAX_SPEED
      imagenes[i].dy = (Rand(0, RAND_MAX) % (MAX_SPEED * 2)) - MAX_SPEED
    Next
  
  
End


Private Procedure draw_imagenes()
  
  Dim i As Integer
  Dim src, dest As New SDL_Rect
    
    For i = 0 To 3
      
      src.x = 0
      src.y = 0
      src.w = Int@(im + 16)
      src.h = Int@(im + 20)
      
      dest.x = imagenes[i].x - Int@(im + 16) / 2
      dest.y = imagenes[i].y - Int@(im + 20) / 2
      dest.w = Int@(im + 16)
      dest.h = Int@(im + 20)
      SDL_UpperBlit(im, src, screen, dest)
      
    Next
    
End


Private Procedure move_imagenes()

  Dim i As Integer
  
    For i = 0 To 3

' Move the image by its motion vector:
      imagenes[i].x += imagenes[i].dx
      imagenes[i].y += imagenes[i].dy

' Turn the image around if it hits the edge of the screen:
      If (imagenes[i].x < 0) Or (imagenes[i].x > Int@(screen + 16) - 1) Then
        imagenes[i].dx = - imagenes[i].dx
      Endif
      
      If (imagenes[i].y < 0) Or (imagenes[i].y > Int@(screen + 20) - 1) Then
        imagenes[i].dy = - imagenes[i].dy
      Endif
    
    Next
    
End

 



 
última edición por vuott el Domingo, 14 Febrero 2016, 18:55; editado 1 vez 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
Vuott:

Acababa de copiar y pegar el listado en un proyecto de consola de gambas.
Lo he probado fuera y dentro del editor. Ventana, fondo negro...no se ve nada.
Es algo de la librería sdl. Versión, supongo.

El problema en estos casos, ¿ Cómo sabes que la librería es la causa realmente ?.

Saludos
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
Shell escribió: [Ver mensaje]
Ventana, fondo negro...no se ve nada.

...la razón podria ser porque tienes el sistema de 32-bit.    



Shell escribió: [Ver mensaje]
Cómo sabes que la librería es la causa realmente ?.

Generalmente problemas, derivados de la librería, provocan errores - señalados - de ausencia de la librería misma o de la función externa llamada.
 



 
última edición por vuott el Martes, 16 Febrero 2016, 13:00; editado 1 vez 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
vuott escribió: [Ver mensaje]
Shell escribió: [Ver mensaje]
Ventana, fondo negro...no se ve nada.

...la razón podria ser porque tienes el sistema de 32-bit.    


Lo más probable.

Eso debería de funcionar de otra forma, detectándose de alguna manera.

Por cierto. En el código se especfican las versiones de tanto la librería libSDL como la libSDL-image"

¿ No seria más práctico dejar solo el nombre la librería ?. Por ejemplo:

'Library "libSDL-1.2:0.11.4"
Library "libSDL"
 


¿ No debería el sistema detectar la ultima versión de la librería instalada y usarla ?.
En ese caso usaría la que tiene el sistema. Pero...¿ y si la que tiene es más antigua que la que solicita el ejemplo ?.
Por eso puede que especifiques la versión.

Saludos
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
Shell escribió: [Ver mensaje]
Por cierto. En el código se especfican las versiones de tanto la librería libSDL como la libSDL-image"


Las funciones externas, alli utilizadas, están contenidas en dos librerias diferentes.



Shell escribió: [Ver mensaje]
¿ No seria más práctico dejar solo el nombre la librería ?.

No siempre es possible.
Mira en la imagen lo que ocurre al usar el simple nombre " libSDL ":

 no_libreria_1455634832_977963
 



 
última edición por vuott el Martes, 16 Febrero 2016, 19:25; editado 1 vez 
vuott - Ver perfil del usuarioEnviar mensaje privado 
Volver arribaPágina inferior
Responder citando   Descargar mensaje  
Mensaje Re: Aprende A Programar Juegos. C++, Python 
 
vuott escribió: [Ver mensaje]

Shell escribió: [Ver mensaje]
¿ No seria más práctico dejar solo el nombre la librería ?.

No siempre es possible.
Mira en la imagen lo que occure al usar el simple nombre " libSDL ":


Si, es como si le faltara encontrar una función. La llama símbolo..

Saludos
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - Ver perfil del usuarioEnviar mensaje privadoVisitar sitio web del usuario 
Volver arribaPágina inferior
Mostrar mensajes anteriores:    
 
OcultarTemas parecidos
Tema Autor Foro Respuestas último mensaje
No hay nuevos mensajes Pilas Engine: Una Libreria De Python Para ... jsbsan Programación en otros lenguajes 5 Lunes, 16 Diciembre 2013, 19:39 Ver último mensaje
Dani26
No hay nuevos mensajes [Python] Tutorial. Aprendiendo A Programar Shell Programación en otros lenguajes 0 Martes, 17 Diciembre 2013, 14:33 Ver último mensaje
Shell
No hay nuevos mensajes [Python] Inventa Tus Propios Juegos De Com... Shell Python 0 Viernes, 12 Febrero 2016, 20:35 Ver último mensaje
Shell
No hay nuevos mensajes [Python] Aprende Python Con Socratica. Shell Python 2 Jueves, 16 Junio 2016, 23:44 Ver último mensaje
Shell
 

Publicar nuevo tema  Responder al tema  Página 1 de 1
 

Usuarios navegando en este tema: 0 registrados, 0 ocultos y 1 invitado
Usuarios registrados conectados: Ninguno


 
Lista de permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
Puede descargar archivos
No puede publicar eventos en el calendario



  

 

cron