main.cpp
- Código: Seleccionar todo
//Lost in Castle
//Version 1.0 BETA
//Alejandro Martinez
#include <SDL/SDL.h>
#include <iostream>
#include <stdio.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_mixer.h>
#include "recursos.h"
int main ( int argc, char** argv ){
SDL_Color fgcolor,bgcolor;
fgcolor.r=255;
fgcolor.g=245;
fgcolor.b=255;
bgcolor.r=0;
bgcolor.g=0;
bgcolor.b=0;
SDL_Surface *choose=IMG_Load("img/choose.png");
SDL_Event event;
SDL_Rect dest;
TTF_Font *fuente;
SDL_Surface *screen;
SDL_Surface *txt;
SDL_Surface *UI;
SDL_Surface *tu;
int proceso=0;
//razas: 1HUMANO,2ORCO,3ELFO
iniciar_sdl();
screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE | SDL_ANYFORMAT | SDL_DOUBLEBUF);
if ( !screen )
{
printf("Error 1x01: %s\n", SDL_GetError());
}
if (TTF_Init() < 0) {
printf("Error 1x02: %s\n",SDL_GetError());
return 1;
}
fuente=TTF_OpenFont("vgasys.ttf",9);
void TTF_Close(TTF_Font *fuente);
////////////////////////////////////////
SDL_WM_SetCaption("Lost In Castle", NULL);
////////////////////////////////////////
UI = IMG_Load ("img/UI.png");
dest.x=0;
dest.y=500;
SDL_BlitSurface(UI, NULL, screen, &dest); //copiamos img en screen
SDL_Flip(screen);
txt = TTF_RenderText_Solid(fuente, "Tu:Hmpf... ¿Que ha pasado, donde estoy?",fgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
while(!proceso){
dialogo1();
}
}
}
}
}
Y aqui el primer dialogo, se que esta un poco confuso, pero es la unica forma que consegui de hacerlo
recursos.h/void dialogo1()
- Código: Seleccionar todo
void dialogo1(){
SDL_Color fgcolor,bgcolor;
fgcolor.r=255;
fgcolor.g=245;
fgcolor.b=255;
bgcolor.r=0;
bgcolor.g=0;
bgcolor.b=0;
SDL_Surface *choose=IMG_Load("img/choose.png");
SDL_Event event;
SDL_Rect dest;
TTF_Font *fuente;
SDL_Surface *screen;
SDL_Surface *txt;
SDL_Surface *UI;
SDL_Surface *tu;
int proceso;
while(!proceso){
while(SDL_PollEvent(&event)){
if(event.type == SDL_KEYDOWN){
if(event.key.keysym.sym == SDLK_RETURN){
txt = TTF_RenderText_Shaded(fuente, "¿?:Tranquilo estas bien, te he salvado ",fgcolor,bgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
while(!proceso){
while(SDL_PollEvent(&event)){
if(event.type == SDL_KEYDOWN){
if(event.key.keysym.sym == SDLK_RETURN){
txt = TTF_RenderText_Shaded(fuente, "Tu:¿Quien habla? ",fgcolor,bgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
while(!proceso){
while(SDL_PollEvent(&event)){
if(event.type == SDL_KEYDOWN){
if(event.key.keysym.sym == SDLK_RETURN){
txt = TTF_RenderText_Shaded(fuente, "¿?:Eso no importa lo importante es recordad quien eres tu Tu:Yo... ",fgcolor,bgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
while(!proceso){
while(SDL_PollEvent(&event)){
if(event.type == SDL_KEYDOWN){
if(event.key.keysym.sym == SDLK_RETURN){
dest.x=150;
dest.y=0;
SDL_BlitSurface(choose,NULL,screen,&dest);
SDL_Flip(screen);
txt = TTF_RenderText_Shaded(fuente, " ",fgcolor,bgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
while(!proceso){
while(SDL_PollEvent(&event)){
if(event.type == SDL_KEYDOWN){
if(event.key.keysym.sym == SDLK_1){
choose=IMG_Load("img/pared1.png");
dest.x=0;
dest.y=0;
SDL_BlitSurface(choose,NULL,screen,&dest);
SDL_Flip(screen);
txt = TTF_RenderText_Solid(fuente, "Asi que eres Erthet de ""Althat"" ",fgcolor);
dest.x=6;
dest.y=368;
SDL_BlitSurface(txt,NULL,screen,&dest);
SDL_Flip(screen);
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
bueno lo primero es invitarles a si tienen una forma mas sencilla de hacerlo que la comentaran jejeje.
Lo segundo es lo siguiente cuando en main.cpp llega a la linea
- Código: Seleccionar todo
while(!proceso){
dialogo1();
}
y pulsas enter, el programa se cierra, se supone que cuando pulsas enter deberia hacer lo que esta en la funcion dialogo1().
he probado a pornelo directamente sin el
- Código: Seleccionar todo
while(!proceso)
pero pasa lo mismo