Bueno, antes que nada, os pongo estas dos (grandes) piezas de código:
;----------;
;Anthro Civ;
;----------;
;| ENGINE |;
;ISOMETRICO;
;----------;
;Variables Globales. No significan nada. Cambiaran eventualmente.
Global mapx, mapy
Global minimapimage
Global iUpdateMiniMap, iShowMiniMap, iOnMiniMap
Global tltilex, tltiley, brtilex, brtiley, scalex#, scaley#, plotx, ploty
Global ProbMar
Global ProbRecurso = 25
Global ProbRec2
;Tamaño de los Tiles:
Const tilewidth = 64
Const tileheight = 32
;Tamaño de un mapa, en Tiles:
Const mapwidth = 512
Const mapheight = 256
;Para identificar el tipo de terreno, hacemos unos cuantos arrays:
Dim TerrenoID(mapwidth,mapheight)
Dim NombreT$(mapwidth,mapheight)
Dim ImagenTile(mapwidth,mapheight)
Dim TasaProd(mapwidth,mapheight);
Dim TasaRiqu(mapwidth,mapheight);Multiplicadores de tasa de produccion, riqueza y poblacion.
Dim TasaPobl(mapwidth,mapheight);
Dim Oceano(mapwidth,mapheight) ;¿Es un oceano? (Los oceanos solo son compatibles con barcos y aereos)
Dim Recurso(mapwidth,mapheight) ;ID del recurso que alberga
Dim Explorado(mapwidth,mapheight,8)
Dim Granja(mapwidth,mapheight,8)
Dim Mina(mapwidth,mapheight,8)
Dim Carretera(mapwidth,mapheight,8)
Dim Ciudad(mapwidth,mapheight,8) ;ID de la ciudad que alberga
;¡Mas arrays! Esta vez, la ciudad.
Dim CiudadID(8)
Dim CiudadNombre$(8)
Dim CiudadRecursoID(8)
Dim CiudadEsPuerto(8)
;Las imagenes de los tiles.
Global oceanotile = LoadImage("images\tileset\water.bmp")
Global hierbatile = LoadImage("images\tileset\isogras.bmp")
Global desiertotile = LoadImage("images\tileset\isodesert.bmp")
Global articotile = LoadImage("images\tileset\artic.bmp")
Global colinastile = LoadImage("images\tileset\isohills.bmp")
Global montanatile = LoadImage("images\tileset\isomountain.bmp")
Global pantanotile = LoadImage("images\tileset\isoswamp.bmp")
Global arbolestile = LoadImage("images\tileset\isotrees.bmp")
;Posicion del mapa inicial en Tiles:
mapx = 0
mapy = 0
;Minimapa:
Global minimapx = 700
Global minimapy = 500
;El array del mapa:
Dim map(mapwidth, mapheight)
;La funcion principal del engine.
Function isometrico()
minimapimage = CreateImage(100, 100)
MaskImage minimapimage, 255, 0, 255
funcInitMiniMap
iShowMiniMap = 1
Cls
funcGetPlayerInput
funcDrawMap
; Debug stuff
; Text 200, 200, MouseX()
; Text 200, 220, MouseY()
; Text 200, 240, mousemapcol + " = " + mousemapcolr + " " + mousemapcolg + " " + mousemapcolb
; Text 200, 260, tilesx
; Text 200, 280, tilesy
; Text 200, 300, mousemapx
; Text 200, 320, mousemapy
; Text 200, 340, scalex#
; Text 200, 360, scaley#
; Text 200, 400, tltilex
; Text 200, 420, tltiley
; Text 200, 440, brtilex
; Text 200, 460, brtiley
If iShowMiniMap = 1 Then
DrawImage minimapimage, minimapx, minimapy
; Draw the rectangle for the screen area on the MiniMap
Color 255, 255, 255
Rect tltilex / scalex# + minimapx, tltiley / scaley# + minimapy, ((brtilex - tltilex) / scalex#), ((brtiley - tltiley) / scaley#), 0
End If
Flip
End Function
; Obtener el input del jugador.
Function funcGetPlayerInput()
; Scroll con el teclado.
If KeyDown(203) And mapx > 0 Then
mapx = mapx - 8
End If
If KeyDown(205) And mapx < (((mapwidth + 1) * tilewidth) + (tilewidth / 2)) - 640
mapx = mapx + 8
End If
If KeyDown(200) And mapy > 0 Then
mapy = mapy - 4
End If
If KeyDown(208) And mapy < ((mapheight + 1) * (tileheight / 2)) + (tileheight / 2) - 480
mapy = mapy + 4
End If
; Decirnos si estamos moviendonos por el mapa.
If iShowMiniMap = 1 Then
If MouseX() >= minimapx And MouseX() <= minimapx + 100 And MouseY() >= minimapy And MouseY() <= minimapy + 100 Then
iOnMiniMap = 1
Else
iOnMiniMap = 0
End If
End If
; Permitir movimiento de camara si el raton no esta sobre el minimapa o el minimapa no es visible.
If iShowMiniMap = 0 Or iOnMiniMap = 0
If MouseDown(1) Then
map(selectx, selecty) = 1
iUpdateMiniMap = 1
End If
If MouseDown(2) Then
map(selectx, selecty) = 0
iUpdateMiniMap = 1
End If
; Esto controla el movimiento del raton.
If MouseX() = 0 And mapx > 0 Then
mapx = mapx - 8
End If
If MouseX() = 639 And mapx < (((mapwidth + 1) * tilewidth) + (tilewidth / 2)) - 640
mapx = mapx + 8
End If
If MouseY() = 0 And mapy > 0 Then
mapy = mapy - 4
End If
If MouseY() = 479 And mapy < ((mapheight + 1) * (tileheight / 2)) + (tileheight / 2) - 480
mapy = mapy + 4
End If
Else
; Esto mueve al lugar clickeado en el minimapa.
If MouseDown(1) Then
iMapXPlace = MouseX() - minimapx - (((brtilex - tltilex) / scalex#) / 2)
iMapYPlace = MouseY() - minimapy - (((brtiley - tltiley) / scaley#) / 2)
mapx = (iMapXPlace * scalex#) * tilewidth
mapy = (iMapYPlace * scaley#) * (tileheight / 2)
; Asegurarnos de que no nos salgamos del area del mapa.
If mapx <= 0 Then
mapx = 0
Else If mapx > (((mapwidth + 1) * tilewidth) + (tilewidth / 2)) - 640 Then
mapx = (((mapwidth + 1) * tilewidth) + (tilewidth / 2)) - 640
End If
If mapy <= 0 Then
mapy = 0
Else If mapy > ((mapheight + 1) * (tileheight / 2)) + (tileheight / 2) - 480 Then
mapy = ((mapheight + 1) * (tileheight / 2)) + (tileheight / 2) - 480
End If
End If
End If
; Permitir que el minimapa sea visto.
If KeyDown(28) Then
If iShowMiniMap = 0 Then
iShowMiniMap = 1
Else
iShowMiniMap = 0
End If
End If
; Actualizar el minimapa si es posible.
If iUpdateMiniMap = 1 Then
funcUpdateMiniMap
iUpdateMiniMap = 0
End If
End Function
; Dibuja el mapa
Function funcDrawMap()
; Calcular cuantos tiles vamos a dibujar...
tltilex = (0 + mapx) / tilewidth
tltiley = ((0 + mapy) / tileheight) * 2
brtilex = ((639 + mapx) / tilewidth) - 1
brtiley = (((479 + mapy) / tileheight) * 2)
; Asegurarnos de que los mapas mas pequeños que la pantalla se vean bien.
If brtilex > mapwidth Then
brtilex = mapwidth
End If
If brtiley > mapheight Then
brtiley = mapheight
End If
; Arreglar los valores para que al moverse se vea bien.
If tltilex > 0 Then
tltilex = tltilex - 1
End If
If tltiley > 0 Then
tltiley = tltiley - 1
End If
If brtilex < mapwidth Then
brtilex = brtilex + 1
End If
If brtiley < mapheight Then
brtiley = brtiley + 1
End If
; Hacer que se llenen los bordes del mapa para asi dar la sensacion de "infinito".
; Arriba
If tltiley = 0 Then
y = -1
For x = tltilex -1 To brtilex
plotx = (x * tilewidth + (y And 1) * (tilewidth / 2)) - mapx
ploty = (y * (tileheight / 2)) - mapy
DrawImage oceanotile, plotx, ploty
Next
End If
; Abajo
If brtiley = mapheight Then
y = brtiley + 1
For x = tltilex -1 To brtilex
plotx = (x * tilewidth + (y And 1) * (tilewidth / 2)) - mapx
ploty = (y * (tileheight / 2)) - mapy
DrawImage oceanotile, plotx, ploty
Next
End If
; Izquierda
If tltilex = 0 Then
x = -1
For y = tltiley To brtiley
plotx = (x * tilewidth + (y And 1) * (tilewidth / 2)) - mapx
ploty = (y * (tileheight / 2)) - mapy
DrawImage oceanotile, plotx, ploty
Next
End If
; Derecha
If brtilex = mapwidth Then
x = brtilex + 1
For y = tltiley To brtiley
plotx = (x * tilewidth + (y And 1) * (tilewidth / 2)) - mapx
ploty = (y * (tileheight / 2)) - mapy
DrawImage oceanotile, plotx, ploty
Next
End If
; Ahora el area principal del mapa que estamos mirando
For y = 0 To mapheight
For x = 0 To mapwidth
plotx = (x * tilewidth + (y And 1) * (tilewidth / 2)) - mapx
ploty = (y * (tileheight / 2)) - mapy
ProbMar = Rnd(0,100)
If ProbMar < 30 Then
TerrenoID(x,y) = 0
NombreT(x,y) = "Oceano"
ImagenTile(x,y) = oceanotile
TasaProd(x,y) = .25
TasaRiqu(x,y) = .75
TasaPobl(x,y) = 1
Oceano(x,y) = 1
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
Else
TerrenoID(x,y) = Rnd(1,7)
Select TerrenoID(x,y)
Case 1
NombreT(x,y) = "Planos"
ImagenTile(x,y) = hierbatile
TasaProd(x,y) = 1
TasaRiqu(x,y) = .75
TasaPobl(x,y) = .25
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 2
NombreT(x,y) = "Desierto"
ImagenTile(x,y) = desiertotile
TasaProd(x,y) = .50
TasaRiqu(x,y) = 1
TasaPobl(x,y) = .50
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 3
NombreT(x,y) = "Artico"
ImagenTile(x,y) = articotile
TasaProd(x,y) = .75
TasaRiqu(x,y) = 1
TasaPobl(x,y) = .25
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 4
NombreT(x,y) = "Colinas"
ImagenTile(x,y) = colinastile
TasaProd(x,y) = 1
TasaRiqu(x,y) = .75
TasaPobl(x,y) = .25
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 5
NombreT(x,y) = "Montanas"
ImagenTile(x,y) = montanatile
TasaProd(x,y) = 1
TasaRiqu(x,y) = .75
TasaPobl(x,y) = .25
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 6
NombreT(x,y) = "Pantano"
ImagenTile(x,y) = pantanotile
TasaProd(x,y) = .75
TasaRiqu(x,y) = 1
TasaPobl(x,y) = .25
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
Case 7
NombreT(x,y) = "Bosque"
ImagenTile(x,y) = arbolestile
TasaProd(x,y) = 1
TasaRiqu(x,y) = .25
TasaPobl(x,y) = .75
Oceano(x,y) = 0
ProbRec = Rnd(0,100)
If ProbRec < ProbRecurso Then
Else
EndIf
For juan = 0 To 8
Explorado(x,y,juan) = 0
Granja(x,y,juan) = 0
Mina(x,y,juan) = 0
Carretera(x,y,juan) = 0
Ciudad(x,y,juan) = 0
Next
DrawImage ImagenTile(x,y), plotx, ploty
End Select
EndIf
Next
Next
End Function
Function funcInitMiniMap()
; Dibujar el buffer del minimapa
SetBuffer ImageBuffer(minimapimage)
For y = 0 To mapheight
For x = 0 To mapwidth
; Reescalar el mapa.
scalex# = mapwidth
scalex# = scalex# / 100
scaley# = mapheight
scaley# = scaley# / 100
; Saber donde se encuentra cada "plot" (?)
plotx = x / scalex#
ploty = y / scaley#
; Poner el color adecuado
Select TerrenoID(x,y)
Case 0
Color 0, 0, 255
Case 1
Color 0, 255, 0
Case 2
Color 255, 255, 0
Case 3
Color 255, 255, 255
Case 4
Color 75, 255, 75
Case 5
Color 150, 255, 150
Case 6
Color 0, 255, 255
Case 7
Color 0, 150, 0
End Select
; Ver el pixel correcto
Plot plotx, ploty
If scalex# < 0.5 Then
Plot plotx + 2, ploty
Plot plotx + 1, ploty
Else If scalex# < 1 Then
Plot plotx + 1, ploty
End If
Next
Next
;Recuperar el dibujo al buffer principal
SetBuffer BackBuffer()
End Function
; Actualiza el minimapa
Function funcUpdateMiniMap()
; Dibujar en el buffer
SetBuffer ImageBuffer(minimapimage)
For y = tltiley To brtiley
For x = tltilex To brtilex
; Otro plotting
plotx = x / scalex#
ploty = y / scaley#
; Poner el color adecuado
Select TerrenoID(x,y)
Case 0
Color 0, 0, 255
Case 1
Color 0, 255, 0
Case 2
Color 255, 255, 0
Case 3
Color 255, 255, 255
Case 4
Color 75, 255, 75
Case 5
Color 150, 255, 150
Case 6
Color 0, 255, 255
Case 7
Color 0, 150, 0
End Select
; Mas plotting
Plot plotx, ploty
If scalex# < 0.5 Then
Plot plotx + 2, ploty
Plot plotx + 1, ploty
Else If scalex# < 1 Then
Plot plotx + 1, ploty
End If
Next
Next
;Recuperar el dibujo en el buffer principal
SetBuffer BackBuffer()
End Function
Y el programa original:
;------------
; Anthro Civ
;------------
;Primeramente, la resolucion y lo demas
Graphics 800, 600, 16, 2
SetBuffer BackBuffer( )
HidePointer
;Titulo de la aplicacion
AppTitle "Anthro Civ v1.0"
;Includes!
Include "blitzui.bb"
Include "sounds.bb"
Include "loadscreen.bb"
Include "Extras\MessageBox.bb"
Include "ciencia.bb"
Include "isoengine.bb"
;Variables!
Global Dificultad1P% = 0
Global JugadoresCPU% = 1
Global MapaCreado = 1
Dim Indice%(8)
Dim Nombre$(8)
Dim Descripcion$(8)
Dim Gobernador$(8)
Dim Oro%(8)
Dim PoliticaID%(8)
Dim Poblacion%(8)
Const P_despo = 0 ; 0 = Despotismo
Const P_monar = 1 ; 1 = Monarquia
Const P_repub = 2 ; 2 = Republica
Const P_democ = 3 ; 3 = Democracia
Const P_comun = 4 ; 4 = Comunismo
Const P_anarq = 5 ; 5 = Anarquia
Global Indice2% = 0
Global Nombre2$ = ""
Global Descripcion2$ = ""
Global Gobernador2$ = ""
Dim genmap(100,100)
Dim backmap(100,100)
Global Edad% = 5000
Global ACDC$ = "aC"
Dim CitaAleatoria$(6)
Citaaleatoria2% = Rand(0,6)
CitaAleatoria$(0) = "No se puede progresar hacia la felicidad por medio de la acción política. -Skinner"
CitaAleatoria$(1) = "El hombre es un animal político. -Aristoteles"
CitaAleatoria$(2) = "No tengo ninguna estima por el hombre que a los veinte años no ha sido nacionalista o comunista. -Daudet"
CitaAleatoria$(3) = "La política es una guerra sin efusión de sangre; la guerra una política con efusión de sangre. -Mao Tse Tung"
CitaAleatoria$(4) = "Las convicciones políticas son como la virginidad: una vez perdidas, no vuelven a recobrarse. -Pi i Maragall"
CitaAleatoria$(5) = "Es muy difícil hacer compatibles la política y la moral. -Bacon"
CitaAleatoria$(6) = "La política es un acto de equilibrio entre la gente que quiere entrar y aquellos que no quieren salir. -Bossuet"
Global trampaactual$ = "Trampa"
Global espiaindice% = 1
Dim AI(8).Civilizacion
;Los archivos de script BlitzBasic (necesarios para la pantalla de carga)
bb_blitzui$ = "blitzui.bb"
bb_blitzui_backup$ = "blitzui_backup.bb"
bb_icons$ = "icons.bb"
bb_loadscreen$ = "LoadScreen.bb"
bb_main$ = "main.bb"
bb_sounds$ = "sounds.bb"
bb_extras_colorpicker$ = "Extras\ColorPicker.bb"
bb_extras_messagebox$ = "Extras\MessageBox.bb"
bb_extras_opensavedialog$ = "Extras\OpenSaveDialog.bb"
;La Pantalla de Carga
Global pantallacarga.TLoadScreen = LoadScreen_Create(9, 8, 150, 0.38, 0.35 )
LoadScreen_SetImage(pantallacarga, "cargando.jpg")
LoadScreen_SetFont(pantallacarga, "Book Antiqua", 20, True)
LoadScreen_SetSound(pantallacarga, "music\Loading_Theme9.mp3" )
LoadScreen_PlaySound(pantallacarga)
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;1
Delay FileSize(bb_blitzui$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;2
Delay FileSize(bb_blitzui_backup$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;3
Delay FileSize(bb_icons$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;4
Delay FileSize(bb_loadscreen$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;5
Delay FileSize(bb_main$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;6
Delay FileSize(bb_sounds$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;7
Delay FileSize(bb_extras_colorpicker$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;8
Delay FileSize(bb_extras_messagebox$)/128
LoadScreen_Update(pantallacarga, True, 0, 98, 39) ;9
Delay FileSize(bb_extras_opensavedialog$)/128
Delay 1000
Color 0,0,0
Text GraphicsWidth()/2, GraphicsHeight() - 160, CitaAleatoria$(CitaAleatoria2%),True,False
Text GraphicsWidth()/2, GraphicsHeight() - 300, "Pulsa la barra espaciadora para empezar.",True,False : Flip
While Not KeyHit(57) : Wend
If LoadScreen_Destroy(pantallacarga) Then DebugLog "La pantalla de carga ha sido destruida..."
;Archivos del interface!
gui_back = LoadImage("images\gui_back.bmp")
;Cargando el interface.
Initialise( )
;Selecciona una dificultad
win_difficulty = Window( 160, 56, 348, 363, "Selecciona una Dificultad", "0", 1, 0, 0, 0 )
btn_difficultyselected = Button( 176, 274, 146, 33, "Sigue...", "0", 1, 0, 0 )
btn_difficultyback = Button( 17, 272, 137, 35, "Atras", "0", 1, 0, 0 )
grp_difficulty = GroupBox( 164, 17, 168, 302, "Selecciona una dificultad de la lista" )
img_veryeasy = ImageBox( 16, 9, 64, 64, "images\difficulties\muyfacil.bmp", 0, 0, 1 )
img_easy = ImageBox( 86, 50, 67, 62, "images\difficulties\facil.bmp", 0, 0, 1 )
img_medium = ImageBox( 17, 97, 64, 64, "images\difficulties\medio.bmp", 0, 0, 1 )
img_hard = ImageBox( 88, 138, 62, 60, "images\difficulties\dificil.bmp", 0, 0, 1 )
img_veryhard = ImageBox( 18, 181, 62, 63, "images\difficulties\muydificil.bmp", 0, 0, 1 )
rad_veryeasy = Radio( 178, 39, "Jefe (el mas facil)", 1, 1 )
rad_easy = Radio( 178, 75, "Senor de la Guerra", 0, 1 )
rad_medium = Radio( 178, 115, "Principe", 0, 1 )
rad_hard = Radio( 178, 159, "Rey", 0, 1 )
rad_veryhard = Radio( 177, 202, "Emperador (el mas dificil)", 0, 1 )
;Salir
win_exit = Window( 225, 110, 227, 268, "Salir", "0", 1, 0, 0, 0 )
btn_yesexit = Button( 100, 53, 117, 28, "Si", "0", 1, 0, 0 )
btn_notexit = Button( 99, 84, 120, 30, "No", "0", 1, 0, 0 )
img_exit = ImageBox( 8, 8, 86, 225, "images\anthrocivexit.bmp", 0, 0, 1 )
lbl_exitquestion = Label( 99, 9, "Estas seguro de " + Chr(10) + "que quieres salir?", 0 )
;Menu principal
win_mainmenu = Window( 247, 33, 169, 361, "Menu Principal", "0", 1, 0, 0, 0 )
btn_singleplayer = Button( 10, 154, 146, 26, "Un Jugador", "0", 1, 0, 0 )
btn_multiplayer = Button( 10, 185, 147, 27, "Multijugador", "0", 1, 0, 0 )
SendMessage( btn_multiplayer, "BM_DISABLE" )
btn_credits = Button( 10, 254, 147, 33, "Creditos", "0", 1, 0, 0 )
btn_exit = Button( 10, 292, 147, 35, "Salir", "0", 1, 0, 0 )
img_title = ImageBox( 7, 6, 152, 142, "images\title.bmp", 0, 0, 1 )
;Selecciona numero de CPU's
win_botnumber = Window( 159, 57, 348, 364, "Selecciona numero de CPU's", "0", 1, 0, 0, 0 )
btn_cpuback = Button( 10, 301, 145, 29, "Atras", "0", 1, 0, 0 )
btn_cpuselected = Button( 171, 300, 162, 30, "Sigue...", "0", 1, 0, 0 )
lbl_cpunumber = Label( 88, 131, "Jugadores de CPU", 0 )
sldcpuplayers = Slider( 58, 103, 228, 19, Float(JugadoresCPU), 1.0, 8.0, 0, 0, "210,210,210", "210,210,210" )
tbox_cpunumber = TextBox( 58, 127, 27, 21, 0, 1, 18, 10, 1 )
SendMessage( tbox_cpunumber, "TM_DISABLE" )
SendMessage( tbox_cpunumber, "TM_SETTEXT", 0, "1" )
;Selecciona tu civilizacion
win_civselect = Window( 71, 131, 501, 226, "Selecciona tu civilizacion", "0", 1, 0, 0, 0 )
btn_civback = Button( 15, 97, 137, 34, "Atras", "0", 1, 0, 0 )
btn_civselected = Button( 15, 139, 137, 35, "A jugar!", "0", 1, 0, 0 )
lst_civselect = ListBox( 15, 12, 139, 54, 20, 20, 10, 0 )
AddListBoxItem( lst_civselect, 1, "Nyapaes", "" )
AddListBoxItem( lst_civselect, 2, "Anglonia", "" )
AddListBoxItem( lst_civselect, 3, "Babonia", "" )
AddListBoxItem( lst_civselect, 4, "Nilosia", "" )
AddListBoxItem( lst_civselect, 5, "Asiatica", "" )
AddListBoxItem( lst_civselect, 6, "Ruski", "" )
AddListBoxItem( lst_civselect, 7, "Niponia", "" )
AddListBoxItem( lst_civselect, 8, "Romania", "" )
AddListBoxItem( lst_civselect, 9, "Grequia", "" )
AddListBoxItem( lst_civselect, 10, "Estados Unidos de Aquerima", "" )
AddListBoxItem( lst_civselect, 11, "Franquia", "" )
AddListBoxItem( lst_civselect, 12, "Germania", "" )
txt_civdesc = TextBox( 161, 14, 331, 25, 1, 0, 18, 10, 0 )
SendMessage( txt_civdesc, "TM_DISABLE" )
SendMessage( txt_civdesc, "TM_SETTEXT", 0, "Selecciona tu civilizacion." )
txt_governor = TextBox( 14, 68, 138, 21, 0, 0, 18, 10, 1 )
SendMessage( txt_governor, "TM_SETTEXT", 0, "Sin Nombre" )
;Window
win_gamestatus = Window( 1, 76, 181, 400, "Estado", "0", 0, 0, 0, 0 )
btn_endturn = Button( 7, 354, 164, 35, "Fin del Turno", "0", 1, 0, 0 )
lbl_population = Label( 5, 153, "Poblacion", 0 )
lbl_year = Label( 5, 130, "Anyo", 0 )
lbl_gold = Label( 7, 86, "Tesoro:", 0 )
lbl_politics = Label( 6, 61, "Politica:", 0 )
lbl_research = Label( 4, 4, "Desarrollando:", 0 )
prg_research = ProgressBar( 5, 29, 167, 22, 0 )
txt_population = TextBox( 55, 151, 114, 21, 0, 0, 18, 10, 0 )
SendMessage( txt_population, "TM_SETTEXT", 0, "" )
SendMessage( txt_population, "TM_DISABLE" )
txt_year = TextBox( 36, 126, 80, 21, 0, 0, 18, 10, 0 )
SendMessage( txt_year, "TM_SETTEXT", 0, "" )
SendMessage( txt_year, "TM_DISABLE" )
txt_gold = TextBox( 48, 82, 123, 21, 0, 1, 18, 10, 0 )
SendMessage( txt_gold, "TM_SETTEXT", 0, "" )
SendMessage( txt_gold, "TM_DISABLE" )
txt_politics = TextBox( 48, 57, 123, 21, 0, 0, 18, 10, 0 )
SendMessage( txt_politics, "TM_SETTEXT", 0, "" )
SendMessage( txt_politics, "TM_DISABLE" )
txt_research = TextBox( 79, 2, 94, 21, 0, 0, 18, 10, 0 )
SendMessage( txt_research, "TM_SETTEXT", 0, "" )
SendMessage( txt_research, "TM_DISABLE" )
;Window
win_gamemenu = Window( 1, 0, 640, 77, "Menu del juego", "0", 1, 1, 0, 0 )
mnut_game = MenuTitle( "Juego" )
mnui_open = MenuItem( mnut_game, "Abrir", "Ctrl+a", "0", 0, 0, 0 )
mnui_save = MenuItem( mnut_game, "Guardar", "Ctrl+g", "0", 0, 0, 0 )
mnui_saveas = MenuItem( mnut_game, "Guardar Como...", "", "0", 0, 0, 0 )
mnui_newgame = MenuItem( mnut_game, "Nuevo Juego", "Ctrl+n", "0", 0, 0, 0 )
mnui_credits = MenuItem( mnut_game, "Creditos", "", "0", 0, 0, 0 )
mnui_exit = MenuItem( mnut_game, "Salir", "Alt+q", "0", 0, 0, 0 )
mnut_government = MenuTitle( "Gobierno" )
mnui_advisors = MenuItem( mnut_government, "Consejeros", "Shift+c", "0", 0, 0, 0 )
mnui_politics = MenuItem( mnut_government, "Cambiar Politica", "", "0", 0, 0, 0 )
mnui_despotism = MenuItem( mnui_politics, "Despotismo", "", "0", 0, 0, 0 )
mnui_monarchy = MenuItem( mnui_politics, "Monarquia", "", "0", 0, 0, 0 )
mnui_democracy = MenuItem( mnui_politics, "Democracia", "", "0", 0, 0, 0 )
mnui_communism = MenuItem( mnui_politics, "Comunismo", "", "0", 0, 0, 0 )
mnui_republic = MenuItem( mnui_politics, "La Republica", "", "0", 0, 0, 0 )
mnui014 = MenuItem( mnui_politics, "-----------", "", "0", 0, 0, 0 )
mnui_revolt = MenuItem( mnui_politics, "Ir a la Revolucion", "", "0", 0, 0, 0 )
mnui_research = MenuItem( mnut_government, "Investigacion", "", "0", 0, 0, 0 )
mnui_diplomacy = MenuItem( mnut_government, "Diplomacia...", "", "0", 0, 0, 0 )
mnut_times = MenuTitle( "El Historiador" )
mnut_orders = MenuTitle( "Ordenes" )
mnui_goto = MenuItem( mnut_orders, "Ir A...", "m", "0", 0, 0, 0 )
mnui_patrol = MenuItem( mnut_orders, "Patrullar", "p", "0", 0, 0, 0 )
mnui_fortress = MenuItem( mnut_orders, "Fortificar", "f", "0", 0, 0, 0 )
mnui021 = MenuItem( mnut_orders, "---------", "", "0", 0, 0, 0 )
mnui_buildcity = MenuItem( mnut_orders, "Construir Ciudad", "b", "0", 0, 0, 0 )
mnui_buildroad = MenuItem( mnut_orders, "Construir Carretera", "", "0", 0, 0, 0 )
mnui_buildrailroad = MenuItem( mnut_orders, "Construir Ferrocarril", "", "0", 0, 0, 0 )
mnui_buildmine = MenuItem( mnut_orders, "Construir Mina", "", "0", 0, 0, 0 )
mnui_buildfarm = MenuItem( mnut_orders, "Construir Regadio", "", "0", 0, 0, 0 )
mnui027 = MenuItem( mnut_orders, "---------", "", "0", 0, 0, 0 )
mnui_attack = MenuItem( mnut_orders, "Atacar", "a", "0", 0, 0, 0 )
mnut_cheats = MenuTitle( "Trampas" )
mnui_activatecheats = MenuItem( mnut_cheats, "Activar Trampa...", "", "0", 0, 0, 0 )
SendMessage( win_gamemenu, "WM_SETLOCKED" )
;Window
win_cheats = Window( 253, 198, 315, 164, "Activar Trampa", "0", 1, 0, 0, 0 )
btn_cheatselected = Button( 177, 87, 113, 38, "Dale!", "0", 1, 0, 0 )
btn_cheatback = Button( 13, 82, 159, 43, "Atras", "0", 1, 0, 0 )
lbl_cheats = Label( 14, 14, "Escribe la trampa aqui:", 0 )
txt_cheats = TextBox( 13, 31, 285, 21, 0, 0, 18, 10, 1 )
SendMessage( txt_cheats, "TM_SETTEXT", 0, "Trampa" )
;Window
win_spycheat = Window( 620, 2, 179, 226, "Espia!", "0", 1, 0, 0, 0 )
btn_indexselectedspy = Button( 100, 163, 70, 34, "OK", "0", 1, 0, 0 )
lbl_indexspy = Label( 5, 138, "Introduce el Numero " + Chr(10) + "del Jugador IA", 0 )
txt_AIplayer1 = TextBox( 10, 13, 156, 21, 0, 0, 18, 10, 1 )
SendMessage( txt_AIplayer1, "TM_DISABLE" )
SendMessage( txt_AIplayer1, "TM_SETTEXT", 0, "Jugador 1" )
txt_AIplayer2 = TextBox( 12, 38, 153, 21, 0, 0, 18, 10, 1 )
SendMessage( txt_AIplayer2, "TM_DISABLE" )
SendMessage( txt_AIplayer2, "TM_SETTEXT", 0, "Jugador 2" )
txt_AIPlayer3 = TextBox( 10, 61, 158, 21, 0, 0, 18, 10, 1 )
SendMessage( txt_AIPlayer3, "TM_DISABLE" )
SendMessage( txt_AIPlayer3, "TM_SETTEXT", 0, "Jugador 3" )
txt_indexinsert = TextBox( 113, 138, 43, 21, 0, 1, 18, 10, 1 )
SendMessage( txt_indexinsert, "TM_SETTEXT", 0, "1" )
SendMessage( win_difficulty, "WM_CLOSE" )
SendMessage( win_exit, "WM_CLOSE" )
SendMessage( win_botnumber, "WM_CLOSE" )
SendMessage( win_civselect, "WM_CLOSE" )
SendMessage( win_gamestatus, "WM_CLOSE" )
SendMessage( win_gamemenu, "WM_CLOSE" )
SendMessage( win_cheats, "WM_CLOSE" )
SendMessage( win_spycheat, "WM_CLOSE" )
mus_title = PlayMusic("music\title_anthrociv.mp3")
Repeat
DrawImage gui_back,0,0
;Draw the GUI and update the mouse
UpdateGUI( )
;Event Handling
Select app\Event
Case EVENT_WINDOW
Select app\WindowEvent
End Select
Case EVENT_MENU
Select app\MenuEvent
End Select
Case EVENT_GADGET
Select app\GadgetEvent
Case btn_singleplayer
StopChannel mus_title
mus_frontend = PlayMusic("music\frontend_theme18.mp3")
SendMessage( win_mainmenu, "WM_CLOSE" )
SendMessage( win_difficulty, "WM_OPEN" )
Case rad_veryeasy
Dificultad1P = 0
Case rad_easy
Dificultad1P = 1
Case rad_medium
Dificultad1P = 2
Case rad_hard
Dificultad1P = 3
Case rad_veryhard
Dificultad1P = 4
Case btn_difficultyback
StopChannel mus_frontend
mus_title = PlayMusic("music\title_anthrociv.mp3")
SendMessage( win_difficulty, "WM_CLOSE" )
SendMessage( win_mainmenu, "WM_OPEN" )
Case btn_difficultyselected
SendMessage( win_difficulty, "WM_CLOSE" )
SendMessage( win_botnumber, "WM_OPEN" )
Case sldcpuplayers
JugadoresCPU = SendMessage( sldcpuplayers, "SM_GETVALUE" )
SendMessage( tbox_cpunumber, "TM_SETTEXT", 0, JugadoresCPU )
Case btn_cpuback
SendMessage( win_botnumber, "WM_CLOSE" )
SendMessage( win_difficulty, "WM_OPEN" )
Case btn_exit
SendMessage( win_mainmenu, "WM_CLOSE" )
SendMessage( win_exit, "WM_OPEN" )
Case btn_yesexit
app\Quit = True
Case btn_notexit
SendMessage( win_exit, "WM_CLOSE" )
SendMessage( win_mainmenu, "WM_OPEN" )
Case btn_cpuselected
SendMessage( win_botnumber, "WM_CLOSE" )
SendMessage( win_civselect, "WM_OPEN" )
Case lst_civselect
Indice2% = SendMessage( lst_civselect, "LM_GETINDEX" )
Nombre2$ = SendMessage( lst_civselect, "LM_GETCAPTION" )
Select Indice2%
Case 1
Descripcion2$ = "Mejoras: Agricultura y Navegacion."
Case 2
Descripcion2$ = "Mejoras: Riqueza y Navegacion."
Case 3
Descripcion2$ = "Mejoras: Construccion e Infanteria."
Case 4
Descripcion2$ = "Mejoras: Agricultura y Navegacion."
Case 5
Descripcion2$ = "Mejoras: Agricultura e Infanteria."
Case 6
Descripcion2$ = "Mejoras: Riqueza y Ciencia."
Case 7
Descripcion2$ = "Mejoras: Agricultura y Riqueza."
Case 8
Descripcion2$ = "Mejoras: Construccion y Riqueza."
Case 9
Descripcion2$ = "Mejoras: Construccion y Ciencia."
Case 10
Descripcion2$ = "Mejoras: Ciencia e Infanteria."
Case 11
Descripcion2$ = "Mejoras: Navegacion e Infanteria."
Case 12
Descripcion2$ = "Mejoras: Infanteria y Navegacion."
End Select
SendMessage( txt_civdesc, "TM_SETTEXT", 0, Descripcion2$ )
Case txt_governor
Gobernador2$ = SendMessage( txt_governor, "TM_GETTEXT" )
Case btn_civback
SendMessage( win_civselect, "WM_CLOSE" )
SendMessage( win_botnumber, "WM_OPEN" )
Case btn_civselected
Indice%(0) = Indice2%
Nombre$(0) = Nombre2$
Descripcion$(0) = Descripcion2$
Gobernador$(0) = Gobernador2$
Oro%(0) = 50
PoliticaID%(0) = P_despo
Poblacion%(0) = 0
For juan = 1 To JugadoresCPU
Indice%(juan) = Rnd(1,12)
Select Indice%(juan)
Case 1
Nombre$(juan) = "Nyapaes"
Case 2
Nombre$(juan) = "Anglonia"
Case 3
Nombre$(juan) = "Babonia"
Case 4
Nombre$(juan) = "Nilosia"
Case 5
Nombre$(juan) = "Asiatica"
Case 6
Nombre$(juan) = "Ruski"
Case 7
Nombre$(juan) = "Niponia"
Case 8
Nombre$(juan) = "Romania"
Case 9
Nombre$(juan) = "Grequia"
Case 10
Nombre$(juan) = "Estados Unidos de Aquerima"
Case 11
Nombre$(juan) = "Franquia"
Case 12
Nombre$(juan) = "Germania"
End Select
Select Indice%(juan)
Case 1
Descripcion$(juan) = "Mejoras: Agricultura y Navegacion."
Case 2
Descripcion$(juan) = "Mejoras: Riqueza y Navegacion."
Case 3
Descripcion$(juan) = "Mejoras: Construccion e Infanteria."
Case 4
Descripcion$(juan) = "Mejoras: Agricultura y Navegacion."
Case 5
Descripcion$(juan) = "Mejoras: Agricultura e Infanteria."
Case 6
Descripcion$(juan) = "Mejoras: Riqueza y Ciencia."
Case 7
Descripcion$(juan) = "Mejoras: Agricultura y Riqueza."
Case 8
Descripcion$(juan) = "Mejoras: Construccion y Riqueza."
Case 9
Descripcion$(juan) = "Mejoras: Construccion y Ciencia."
Case 10
Descripcion$(juan) = "Mejoras: Ciencia e Infanteria."
Case 11
Descripcion$(juan) = "Mejoras: Navegacion e Infanteria."
Case 12
Descripcion$(juan) = "Mejoras: Infanteria y Navegacion."
End Select
Select Indice%(juan)
Case 1
Gobernador$(juan) = "Rodriguez Pescadero"
Case 2
Gobernador$(juan) = "Reina Isabel XII"
Case 3
Gobernador$(juan) = "Nabocodosur"
Case 4
Gobernador$(juan) = "Ramises V"
Case 5
Gobernador$(juan) = "Chuang Ching Chung"
Case 6
Gobernador$(juan) = "Ilich Ulianovich Linin"
Case 7
Gobernador$(juan) = "Mutsobitsi Imokawa"
Case 8
Gobernador$(juan) = "Julii Quaesar"
Case 9
Gobernador$(juan) = "Pedrocles"
Case 10
Gobernador$(juan) = "Abe Locohn"
Case 11
Gobernador$(juan) = "Jacques Chubaque"
Case 12
Gobernador$(juan) = "Arrolf Himmler"
End Select
Oro%(juan) = 50 * Dificultad1P
PoliticaID%(juan) = P_despo
Poblacion%(juan) = 0
Next
SendMessage( win_civselect, "WM_CLOSE" )
SendMessage( win_gamemenu, "WM_OPEN" )
SendMessage( win_gamestatus, "WM_OPEN" )
Repeat
UpdateGUI()
If MapaCreado = 1 Then
isometrico()
MapaCreado = 0
EndIf
SendMessage( txt_population, "TM_SETTEXT", 0, Str Poblacion%(0) )
SendMessage( txt_year, "TM_SETTEXT", 0, Edad% + " " + ACDC$ )
SendMessage( txt_gold, "TM_SETTEXT", 0, Oro%(0) + " U.M." )
Select PoliticaID%(0)
Case P_despo
SendMessage( txt_politics, "TM_SETTEXT", 0, "Despotismo" )
Case P_monar
SendMessage( txt_politics, "TM_SETTEXT", 0, "Monarquia" )
Case P_repub
SendMessage( txt_politics, "TM_SETTEXT", 0, "Republica" )
Case P_democ
SendMessage( txt_politics, "TM_SETTEXT", 0, "Democracia" )
Case P_comun
SendMessage( txt_politics, "TM_SETTEXT", 0, "Comunismo" )
Case P_anarq
SendMessage( txt_politics, "TM_SETTEXT", 0, "Anarquia" )
End Select
Select app\Event
Case EVENT_WINDOW
Select app\WindowEvent
End Select
Case EVENT_MENU
Select app\MenuEvent
Case mnui_activatecheats
SendMessage( win_cheats, "WM_OPEN" )
End Select
Case EVENT_GADGET
Select app\GadgetEvent
Case txt_cheats
trampaactual = SendMessage( txt_cheats, "TM_GETTEXT" )
Case btn_cheatselected
If trampaactual = "ninoaleman" Then
MessageBox("Has activado el espia aleman!", "Trampa activada!", 1)
SendMessage( win_spycheat, "WM_OPEN" )
Else
MessageBox("Codigo Incorrecto.", "Ups...", 1)
EndIf
Case btn_cheatback
SendMessage( win_cheats, "WM_CLOSE" )
Case txt_indexinsert
espiaindice% = SendMessage( txt_indexinsert, "TM_GETTEXT" )
Case btn_indexselectedspy
If espiaindice% < 9 Then
SendMessage( txt_AIPlayer1, "TM_SETTEXT", 0, Nombre$(espiaindice%) )
SendMessage( txt_AIPlayer2, "TM_SETTEXT", 0, Descripcion$(espiaindice%) )
SendMessage( txt_AIPlayer3, "TM_SETTEXT", 0, Gobernador$(espiaindice%) )
Else
MessageBox("No puedes poner mas del" + Chr(10) + "maximo de jugadores de IA!", "Control de sanidad...", 1)
EndIf
End Select
End Select
DrawMouse()
ResetEvents()
Flip
Cls
Until KeyHit( 1 ) Or app\Quit = True
End Select
End Select
;Draw the mouse
DrawMouse( )
;Reset all GUI events
ResetEvents( )
Flip
Cls
Until KeyHit( 1 ) Or app\Quit = True
;Liberar todas las imagenes creadas por el BlitzUI
Destroy( )
End
Bien, pues quiero decir lo siguiente: he intentado poner el mapa detrás del GUI pero lo que hace es aparecer y desaparecer al instante. (isometrico() es la funcion que genera el mapa) ¿Alguien sabe donde coloco isometrico()?
solo un detalle, si puede en el asunto no pongas "otro problema mas" intenta poner el problema en el asunto. Y bueno... de momento me da pereza leerme todo ese puñao de codigo
bucle principal
{
actualizacion de variables()
lectura del teclado y raton()
pintar escena()
{
pintar escenario()
pintar objetos()
}
pintar interfaz()
{
pintar ventanas y/o paneles()
pintar botones, textos, etc...()
}
enviar informacion a la pantalla()
procesar audio()
}
Esto seria un esquema sencillo de estructura de un bucle central de un juego. Tienes que tener en cuenta el orden de dibujado, sobre todo teniendo en cuenta que Blitz si no recuerdo mal para el 2D no cuenta con coordenada Z para indicar la profundiad del sprite como seria en el caso de Div Game Studio (y Fenix) o mi libreria por ejemplo ahorrandote la ordenacion, ya que lo primero que dibujes sera lo que quede al fondo y lo ultimo lo que quede por encima. Primero tendras que pintar la escena: con fondo, escenario y sus objetos, despues tendras que pintar los elementos de la interfaz: paneles, botones, textos, mapas...
Otro consejo, no te molestes en poner parrafadas de codigo para que te indiquen donde meter las cosas. La gente no se molestara en leerlas y solo te explicaran la solucion, no te van a resolver el puzzle por ti.
Salu2...
Bien, pero hay otro problemilla, y es que, cada vez que pongo el mapa en el bucle principal, se vuelve a hacer una y otra vez. ¿Algun consejillo para eso?
Logicamente todo lo que metas dentro de un bucle se ejecutara tantes veces como iteraciones se produzcan.
No me he leido el codigo, pero si lo que quieres hacer es inicializar el mapa, eso deberias hacerlo antes del bucle principal, por lo que solo se ejecutaria una vez.
No te lo tomes a mal, pero creo que te falta un poco de base.
Deberias leerte algo de documentacion sobre metodologia, algoritmos, etc.
Cita de: "bnl"Deberias leerte algo de documentacion sobre metodologia, algoritmos, etc.
Que tal empezar por los propios tutoriales de iniciacion a la programacion del Blitz3D acompañados de una previa lectura de su completa documentacion y al codigo fuente de sus ejemplos? :roll: