|
Post by atomose on Dec 27, 2022 17:32:12 GMT -5
SURVIVAL GAME

Here is a open source to my game Survival Re-Evolution. The goal, in the lite version, is to survival 15mn. If a monster touch you, you lose 1 life. When you have 0 life, you lose the game !
Ho and of course, more you run ... more monsters are coming 
|
|
|
Post by xxgeek on Dec 27, 2022 22:05:45 GMT -5
One thing I noticed atomose is the score is hard to read with the flickering.
When I put the line of code updating the score into the sub removeSprites as shown
sub removeSprites list$ #main.map, "color red; place 1110 30;\"; " Survive ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" \ Vies : "; vie; " "
there is a lot less flickering, easier to read, and the score still updates.
Although I am not a gamer, I still appreciate your posts, thanks for sharing.
|
|
|
Post by dan1101 on Dec 30, 2022 6:36:45 GMT -5
Nice little game. In general, it works as advertised. Sprite movement is impressive considering the large number of sprites on the screen. Keyboard response to the arrow keys for directional control is very good. Scrolling is fairly smooth, if not perfect. Although there is a slight hesitation at regular intervals while scrolling continuously, it is not enough to interfere significantly with game play. On the whole, the game functions successfully.
The bad news is that the .exe packaged in the .zip is flagged by Norton Antivirus as a security threat, probably due to its relative newness, and automatically deleted. The threat is identified by Norton as "WS.Reputation.1" This designation is a generic detection category used by Norton Antivirus, Norton Internet Security and other antivirus products from Symantec for a file that appears to have trojan-like features or behavior. This does not mean it is an actual threat or malware, just that it has certain characteristics that are shared by malware.
The good news is that the deleted .exe file is superfluous for anyone who has Liberty BASIC installed. The .bas runs fine in Liberty BASIC without the .exe and the game works.
Three other reactions to the game:
1.) I agree with xxgeek that the flicker in the score display is a bit distracting. Using his fix improved the display but did not entirely correct it on my computer.
2.) 15 minutes is FAR too long for the game to run. I think that very few players, if any, will maintain interest for that long. When I run the game, the timer appears to be counting down from 12 minutes, rather than 15. If I fail and the game restarts, it then appears to be counting down from 16 rather than 15. In either case, I think two or three minutes would be a more reasonable duration for a game of this type.
3.) There appears to be no acknowledgement of your success if you actually do manage to survive. There is no "Congratulations, you won" message. The game appears to simply reset the timer and start over. I admit that I have not stuck with the game for the full 15 (or 12?) minutes to test this. I might be overlooking something, but I did not find any kind of victory acknowledgement in the code.
Thank you for sharing your game.
|
|
|
Post by atomose on Dec 30, 2022 11:04:34 GMT -5
hi ! thank you for testing my game. This is just a prototype to show people how to make this type of game. Here the game is not finished at all. I also noticed the problem with the .exe which is however the official .exe of LB ... it's annoying. As for the timer, I set it to 5 minutes now and there is no longer the problem of the minutes running back. I also fixed the flickering of the writings to make it look nicer. The new version below also allows better management of sprites. You can now go to 100 sprites without slowing down (against 70 before) and 150 max (against 100 before) if you have a good processor ^^. there is no victory condition yet (even with the timer) I think I will add it later. here is the new code  (i will update the first post)
' Creat By Atomose Studio 2022 with LibertyBasic 4.51 pro
nomainwin
'------------------------ CHARGEMENT DES VARIABLES DU JEU ( CARTE ET UNITEES ) ------------------------------------------------------------------------------------------------------
[ini] dir$ = "" : file$ = "data.txt" if fileExist(dir$,file$) = 0 then gosub [print] : goto [start] gosub [input] if pass$ = "1" then end pass$ = "1" if save = 1 then goto [loaded]
[start] perso1x = 19 : perso1y = 8 : valIniX = 9 : valIniY = 2 global creepsMAX creepsMAX = 20
[loaded] pers$="perso1" : FINALtimer = 4 sprites$ = "echelle cache creepA perso1 perso1b perso1c perso1d perso2 perso2b perso2c perso2d perso3 perso3b perso3c perso3d perso4 perso4b perso4c perso4d mur terre mur2 mur3 mur4 mur5 mur6 mur7 mur8 mur9" for s = 1 to 29 loadbmp word$(sprites$,s), "data\"+word$(sprites$,s)+".bmp" next
dim p(x,y) : global dy,dx WindowWidth = 302 : WindowHeight = 602 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) x= 40 : y= 25
graphicbox #main.map, 0, 0, WindowWidth, WindowHeight open "Survival" for window_popup as #main #main.map, "down; fill black; color black; backcolor black"
redim p(x,y) data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,08,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,10,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,09,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,11,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03
for b=0 to y-1 for a=0 to x-1 read valeur : p(a,b)= valeur next a next b
'------------------------ CHARGEMENTS DE TEXTURES DU JEU ------------------------------------------------------------------------------------------------------
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main2.map, 2, 2, WindowWidth-5, WindowHeight-4 open "Survival" for window_popup as #main2 #main2.map, "setfocus; down; fill black; font ink_free Roman 30; color yellow; backcolor black" #main2.map, "place 330 400 ;\"; "Chargement des données du monde ..."
num1 = 0 : maxx= 40 : maxy= 30 for i = 0 to 7 for j = 0 to 4 num1 = 0 for y=0 to 4 for x= 0 to 4 num1 = num1 +1 sprName$="spr";num1 select case p(x+i*5,y+j*5) case 0 print #main.map,"addsprite ";sprName$;" terre" case 2 print #main.map,"addsprite ";sprName$;" mur2" case 4 print #main.map,"addsprite ";sprName$;" mur3" case 3 print #main.map,"addsprite ";sprName$;" mur" case 6 print #main.map,"addsprite ";sprName$;" mur5" case 7 print #main.map,"addsprite ";sprName$;" mur4" case 8 print #main.map,"addsprite ";sprName$;" mur6" case 9 print #main.map,"addsprite ";sprName$;" mur9" case 10 print #main.map,"addsprite ";sprName$;" mur7" case 11 ' print #main.map,"addsprite ";sprName$;" mur8" end select #main.map,"spritexy ";sprName$;" ";(x)*60;" ";300+(y)*60 'at 0, 300 next next
#main.map "drawsprites" #main.map "place 0 0; boxfilled 300 300 " bmp$="bg";right$(str$(100+i), 2);right$(str$(100+j), 2) #main.map "getbmp ";bmp$;" 0 0 300 600"
for k = 1 to num1 sprName$="spr";k print #main.map,"removesprite ";sprName$ next next next
valIniXold = valIniX : valIniYold = valIniY : valX = 0 : valY = 0 : num1 = 0 close #main : close #main2
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main.map, 3, 30, WindowWidth-6, WindowHeight-6 graphicbox #main.map2, 3, 3, WindowWidth-6, 28 open "Survival" for window_popup as #main #main, "trapclose [close]" #main.map, "setfocus; down; fill white" #main.map2, "down; fill ";20;" ";20;" ";20 #main.map2, "font ink_free Roman 12; color white"
'------------------------ CHARGEMENT DES PERSONNAGES ------------------------------------------------------------------------------------------------------
print #main.map,"addsprite perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d" print #main.map,"addsprite perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d" print #main.map,"addsprite perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d" print #main.map,"addsprite perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d"
global creeps, perso1x, perso1y, valIniX, valIniY, vie, creepsMAX, creepsMAXold, timerNUM2, scale creeps = 100 : vie = 50 : creepsMAXold = 0 dim creepPosX(creeps) dim creepPosY(creeps) ' dim creepHealth(creeps)
for c = 1 to creepsMAX print #main.map,"addsprite creepA";c;" creepA" ' creepHealth(c) = int(rnd(1)*10+1) RNDzones = int(rnd(1)*4+1) if RNDzones = 1 then creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 2 then creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 3 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) if RNDzones = 4 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) next c
print #main.map, "addsprite cache cache; spritexy cache 0 0" print #main.map, "addsprite echelle echelle echelle"
'------------------------ BOUCLE PRINCIPALE DU JEU ------------------------------------------------------------------------------------------------------
[endLEVEL] #main.map, "discard" #main.map2, "backcolor ";20;" ";20;" ";20;"; place 500 18;\"; " Survive ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" Vies : "; vie; " "';creepsMAX
bgList$ = "" for i = 0 to 7 for j = 0 to 4 realX=(i*5-valIniX)*60 : realY=(j*5-valIniY)*60 if realX >= 0-298 and realX < WindowWidth-7 and realY >= 0-298 and realY < WindowHeight-6 then bmp$="bg";right$(str$(1000+i), 2);right$(str$(1000+j), 2) #main.map,"addsprite ";bmp$; " ";bmp$;"; spritexy ";bmp$; " " ;realX;" ";realY bgList$ = bgList$+" "+bmp$ end if next next
dy = 0 : dx = 0 : scale = 0.05 call readJStick 1
if dx = 2 and timerNUM >10 then confirm "Voulez vous quitter le jeu ?";quit$ if quit$ = "yes" then pass$ = "0" : save = 1 : gosub [print] : timer 0 : close #main : end dx = 0 end if
if dy <> 0 then dx = 0 valIniX = valIniX+(1*dx)*scale : perso1x = perso1x +(1*dx)*scale : valIniY = valIniY+(1*dy)*scale : perso1y = perso1y +(1*dy)*scale
select case p(INT(perso1x+0.5),INT(perso1y+0.55)) case 0 select case dx case 1 perso = 2 : pers$="perso3" case -1 perso = 1 : pers$="perso2" end select select case dy case 1 perso = 3 : pers$="perso1" case -1 perso = 4 : pers$="perso4" end select case else select case dx case 1 valIniX = valIniX -1*scale : perso1x = perso1x -1*scale : pers$="perso3" case -1 valIniX = valIniX +1*scale : perso1x = perso1x +1*scale : pers$="perso2" end select select case dy case 1 valIniY = valIniY -1*scale : perso1y = perso1y -1*scale : pers$="perso1" case -1 valIniY = valIniY +1*scale : perso1y = perso1y +1*scale : pers$="perso4" end select end select
call advanceCreeps print #main.map, "spritexy echelle ";int((20-valIniX)*60);" ";int((5-valIniY)*60)-10;"; spritetofront echelle" print #main.map, "SpriteVisible cache on; spritetofront cache" print #main.map, "spritexy ";pers$;" ";int((WindowWidth/2)-30);" ";int((WindowHeight/2)-30);"; SpriteVisible ";pers$;" on; spritetofront ";pers$ if dx<>0 or dy<>0 then #main.map, "cyclesprite ";pers$;" 1 once" #main.map "drawsprites"
call removeSprites bgList$ print #main.map, "SpriteVisible ";pers$;" off" timerNUM = timerNUM + 1 : if timerNUM >3720 then timerNUM = 1 : timerNUM2 = timerNUM2 + 1 : vie = vie +1 : gosub [upgradeNUMBERmonsters] call Sleep 1 : goto [endLEVEL]
[close] timer 0 : close #main : end
'------------------------ FONCTIONS ------------------------------------------------------------------------------------------------------
function GetAsyncKeyState(key) calldll #user32, "GetAsyncKeyState",key as long,GetAsyncKeyState as long if GetAsyncKeyState<>0 then GetAsyncKeyState=1 end function
sub readJStick n if GetAsyncKeyState(_VK_ESCAPE) then dx = 2 if GetAsyncKeyState(asc("Z")) or GetAsyncKeyState(_VK_UP) then dy = -1 if GetAsyncKeyState(asc("W")) or GetAsyncKeyState(_VK_UP) then dy = -1 if GetAsyncKeyState(asc("S")) or GetAsyncKeyState(_VK_DOWN) then dy = 1 if GetAsyncKeyState(asc("Q")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 if GetAsyncKeyState(asc("A")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 if GetAsyncKeyState(asc("D")) or GetAsyncKeyState(_VK_RIGHT) then dx = 1 end sub
sub removeSprites list$ while 1 i=i+1 spr$=word$(list$, i) if spr$ = "" then exit while print #main.map,"removesprite ";spr$ wend end sub
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
function fileExist(dir$,file$) dim info$(10, 10) files dir$,file$, info$( if val(info$(0, 0)) > 0 then fileExist = 1 else fileExist = 0 end if end function
'----- SYSTEM GESTION SPRITES -------------------------------------------------------------------------------------------------------------------------------------------------------------------
sub advanceCreeps for thisCreep = 1 to creepsMAX if int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60) then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.030 if int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)+20 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.030 if int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60) then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.024 if int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)+20 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.024 #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10);"; spritetofront creepA";thisCreep direction = int(rnd(1)*4+1) : jump = rnd(1)*0.03+0.03 select case direction case 1 creepPosX(thisCreep) = creepPosX(thisCreep) + jump case 2 creepPosX(thisCreep) = creepPosX(thisCreep) - jump case 3 creepPosY(thisCreep) = creepPosY(thisCreep) + jump case 4 creepPosY(thisCreep) = creepPosY(thisCreep) - jump end select '--re-creation-sprite----- if (int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)-10 and int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60)+40) AND (int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)-30 and int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60)+20) then vie = vie - 1 : if vie <= 0 then notice " " + chr$(13) + "GAME OVER ! let's try again !" : vie = 50 : timerNUM2 = 0 : timerNUM = 0 RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(thisCreep) = (rnd(1)*2+10) : creepPosY(thisCreep) = (rnd(1)*12+7) case 2 creepPosX(thisCreep) = (rnd(1)*2+27) : creepPosY(thisCreep) = (rnd(1)*12+7) case 3 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+6.5) case 4 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+17.5) end select print #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10) end if '--------------- next thisCreep end sub
'------------------------ ADD MORE MONSTERS ------------------------------------------------------------------------------------------------------
[upgradeNUMBERmonsters] creepsMAXold = creepsMAX : creepsMAX = creepsMAX + 5 : if creepsMAX > creeps then creepsMAX = creeps for c = (creepsMAXold+1) to creepsMAX print #main.map,"addsprite creepA";c;" creepA" ' creepHealth(c) = int(rnd(1)*10+1) RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) case 2 creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) case 3 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) case 4 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) end select next c return
'------------------------ SYSTEME DE SAUVEGARDE ET CHARGEMENT DES DONNEES DU JEU ------------------------------------------------------------------------------------------------------
[file] pass$ = "0" : save = 0 : perso1x = 19 : perso1y = 32 : valIniX = perso1x-10 : valIniY = perso1y-6 gosub [print] : goto [start] [print] open "data.txt" for output as #secu print #secu, pass$ print #secu, save print #secu, perso1x print #secu, perso1y print #secu, valIniX print #secu, valIniY print #secu, vie print #secu, creeps print #secu, creepsMAX print #secu, timerNUM2 close #secu return
[input] open "data.txt" for input as #secu input #secu, pass$ input #secu, save input #secu, perso1x input #secu, perso1y input #secu, valIniX input #secu, valIniY input #secu, vie input #secu, creeps input #secu, creepsMAX input #secu, timerNUM2 close #secu return
|
|
|
Post by tsh73 on Dec 30, 2022 12:37:32 GMT -5
Idea with light circle is really (REALLY!) cool. Me never thought one could do round light spot with rectangular tiles ; Shadow under creatures should better be removed, I think - it does not add much then they go above terrain but definitely looks weird then creatures swarm one atop other. Last thing. "Survive"? Being a skeleton you are already technically dead 
|
|
|
Post by atomose on Dec 30, 2022 13:02:37 GMT -5
thx tsh73 ^^ light circle is a giant sprite, its a fun possibility  . y i think i will remoove shadow under monster. I will rework the sprite to ^^ YES, THIS SKELETON IS ALIVE !!!! 
|
|
|
Post by atomose on Jan 1, 2023 6:47:11 GMT -5
new update! the AIs are much smarter: Now, instead of rushing at the player, there is a detection of the distance between the monsters and the player. If the monster enters the player's field of vision, it attacks the player, otherwise it wanders around the map. Likewise, if the monster leaves the field of vision or is distanced by the player, the latter stops following the player and wanders around the map. I also merged the two graphicboxes as much as possible so that it gives a united window. The texts have also been reworked. The game is now more fluid, the timer is at 3mn. EDIT : for leave the game use "escap" keyboard 
' Creat By Atomose Studio 2022-2023 with LibertyBasic 4.51 pro ' full game will be available on "atomose.fr"
nomainwin
'------------------------ CHARGEMENT DES VARIABLES DU JEU ( CARTE ET UNITEES ) ------------------------------------------------------------------------------------------------------
[ini] dir$ = "" : file$ = "data.txt" if fileExist(dir$,file$) = 0 then gosub [print] : goto [start] gosub [input] if pass$ = "1" then end pass$ = "1" if save = 1 then goto [loaded]
[start] perso1x = 19 : perso1y = 8 : valIniX = 9 : valIniY = 2 global creepsMAX creepsMAX = 40
[loaded] pers$="perso1" : FINALtimer = 2 sprites$ = "echelle cache creepA perso1 perso1b perso1c perso1d perso2 perso2b perso2c perso2d perso3 perso3b perso3c perso3d perso4 perso4b perso4c perso4d mur terre mur2 mur3 mur4 mur5 mur6 mur7 mur8 mur9" for s = 1 to 29 loadbmp word$(sprites$,s), "data\"+word$(sprites$,s)+".bmp" next
dim p(x,y) : global dy,dx WindowWidth = 302 : WindowHeight = 602 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) x= 40 : y= 25
graphicbox #main.map, 0, 0, WindowWidth, WindowHeight open "Survival" for window_popup as #main #main.map, "down; fill black; color black; backcolor black"
redim p(x,y) data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,08,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,10,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,09,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,11,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03
for b=0 to y-1 for a=0 to x-1 read valeur : p(a,b)= valeur next a next b
'------------------------ CHARGEMENTS DE TEXTURES DU JEU ------------------------------------------------------------------------------------------------------
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main2.map, 2, 2, WindowWidth-5, WindowHeight-4 open "Survival" for window_popup as #main2 #main2.map, "setfocus; down; fill black; font ink_free Roman 30; color yellow; backcolor black" #main2.map, "place 330 400 ;\"; "Chargement des données du monde ..."
num1 = 0 : maxx= 40 : maxy= 30 for i = 0 to 7 for j = 0 to 4 num1 = 0 for y=0 to 4 for x= 0 to 4 num1 = num1 +1 sprName$="spr";num1 select case p(x+i*5,y+j*5) case 0 print #main.map,"addsprite ";sprName$;" terre" case 2 print #main.map,"addsprite ";sprName$;" mur2" case 4 print #main.map,"addsprite ";sprName$;" mur3" case 3 print #main.map,"addsprite ";sprName$;" mur" case 6 print #main.map,"addsprite ";sprName$;" mur5" case 7 print #main.map,"addsprite ";sprName$;" mur4" case 8 print #main.map,"addsprite ";sprName$;" mur6" case 9 print #main.map,"addsprite ";sprName$;" mur9" case 10 print #main.map,"addsprite ";sprName$;" mur7" case 11 ' print #main.map,"addsprite ";sprName$;" mur8" end select #main.map,"spritexy ";sprName$;" ";(x)*60;" ";300+(y)*60 'at 0, 300 next next
#main.map "drawsprites" #main.map "place 0 0; boxfilled 300 300 " bmp$="bg";right$(str$(100+i), 2);right$(str$(100+j), 2) #main.map "getbmp ";bmp$;" 0 0 300 600"
for k = 1 to num1 sprName$="spr";k print #main.map,"removesprite ";sprName$ next next next
valIniXold = valIniX : valIniYold = valIniY : valX = 0 : valY = 0 : num1 = 0 close #main : close #main2
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main.map, 0, _WS_BORDER, 0, 0 stylebits #main.map2, 0, _WS_BORDER, 0, 0
graphicbox #main.map, 3, 30, WindowWidth-6, WindowHeight-33 graphicbox #main.map2, 3, 3, WindowWidth-6, 27 open "Survival" for window_popup as #main #main, "trapclose [close]" #main.map, "setfocus; down; fill ";20;" ";20;" ";20 #main.map2, "down; fill ";20;" ";20;" ";20 #main.map2, "font ink_free Roman 12; color white"
'------------------------ CHARGEMENT DES PERSONNAGES ------------------------------------------------------------------------------------------------------
print #main.map,"addsprite perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d" print #main.map,"addsprite perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d" print #main.map,"addsprite perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d" print #main.map,"addsprite perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d"
global creeps, perso1x, perso1y, valIniX, valIniY, vie, creepsMAX, creepsMAXold, timerNUM2, scale creeps = 100 : vie = 50 : creepsMAXold = 0 dim creepPosX(creeps) dim creepPosY(creeps)
for c = 1 to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) if RNDzones = 1 then creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 2 then creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 3 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) if RNDzones = 4 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) next c
print #main.map, "addsprite cache cache; spritexy cache 0 0" print #main.map, "addsprite echelle echelle echelle"
'------------------------ BOUCLE PRINCIPALE DU JEU ------------------------------------------------------------------------------------------------------
[endLEVEL] #main.map, "discard" #main.map2, "backcolor ";20;" ";20;" ";20;"; color green ;font ink_free Roman 14 bold; place 500 25;\"; "Survive ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" " #main.map2, "backcolor ";20;" ";20;" ";20;"; color red; place 680 25;\"; "Vies : "; vie; " "
bgList$ = "" for i = 0 to 7 for j = 0 to 4 realX=(i*5-valIniX)*60 : realY=(j*5-valIniY)*60 if realX >= 0-298 and realX < WindowWidth-7 and realY >= 0-298 and realY < WindowHeight-6 then bmp$="bg";right$(str$(1000+i), 2);right$(str$(1000+j), 2) #main.map,"addsprite ";bmp$; " ";bmp$;"; spritexy ";bmp$; " " ;realX;" ";realY bgList$ = bgList$+" "+bmp$ end if next next
dy = 0 : dx = 0 : scale = 0.05 call readJStick 1
if dx = 2 and timerNUM >10 then confirm "Voulez vous quitter le jeu ?";quit$ if quit$ = "yes" then pass$ = "0" : save = 1 : gosub [print] : timer 0 : close #main : end dx = 0 end if
if dy <> 0 then dx = 0 valIniX = valIniX+(1*dx)*scale : perso1x = perso1x +(1*dx)*scale : valIniY = valIniY+(1*dy)*scale : perso1y = perso1y +(1*dy)*scale
select case p(INT(perso1x+0.5),INT(perso1y+0.55)) case 0 select case dx case 1 perso = 2 : pers$="perso3" case -1 perso = 1 : pers$="perso2" end select select case dy case 1 perso = 3 : pers$="perso1" case -1 perso = 4 : pers$="perso4" end select case else select case dx case 1 valIniX = valIniX -1*scale : perso1x = perso1x -1*scale : pers$="perso3" case -1 valIniX = valIniX +1*scale : perso1x = perso1x +1*scale : pers$="perso2" end select select case dy case 1 valIniY = valIniY -1*scale : perso1y = perso1y -1*scale : pers$="perso1" case -1 valIniY = valIniY +1*scale : perso1y = perso1y +1*scale : pers$="perso4" end select end select
'--------------- SPRITES GESTION ---------------- for thisCreep = 1 to creepsMAX dist = sqr(abs(perso1x-creepPosX(thisCreep))*abs(perso1x-creepPosX(thisCreep)) + abs(perso1y-creepPosY(thisCreep))*abs(perso1y-creepPosY(thisCreep))) if dist <= 4 then if int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60) then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.030 if int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)+20 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.030 if int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60) then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.024 if int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)+20 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.024 gosub [directionSPRITES] '--re-creation-sprite----- if (int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)-10 and int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60)+40) AND (int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)-30 and int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60)+20) then vie = vie - 1 : if vie <= 0 then notice " " + chr$(13) + "GAME OVER ... let's try again !" : vie = 50 : timerNUM2 = 0 : timerNUM = 0 RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(thisCreep) = (rnd(1)*2+10) : creepPosY(thisCreep) = (rnd(1)*12+7) case 2 creepPosX(thisCreep) = (rnd(1)*2+27) : creepPosY(thisCreep) = (rnd(1)*12+7) case 3 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+6.5) case 4 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+17.5) end select end if end if if dist > 4 then choix = int(rnd(1)*4+1) if choix = 1 and creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.10 if choix = 2 and creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.10 if choix = 3 and creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.10 if choix = 4 and creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.10 gosub [directionSPRITES] end if #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10);"; spritetofront creepA";thisCreep
'--------------- next '----------------------------------------------
print #main.map, "spritexy echelle ";int((20-valIniX)*60);" ";int((5-valIniY)*60)-10;"; spritetofront echelle" print #main.map, "SpriteVisible cache on; spritetofront cache" print #main.map, "spritexy ";pers$;" ";int((WindowWidth/2)-30);" ";int((WindowHeight/2)-30);"; SpriteVisible ";pers$;" on; spritetofront ";pers$ if dx<>0 or dy<>0 then #main.map, "cyclesprite ";pers$;" 1 once" #main.map "drawsprites"
call removeSprites bgList$ print #main.map, "SpriteVisible ";pers$;" off" timerNUM = timerNUM + 1 if timerNUM >=3720 then timerNUM = 1 : timerNUM2 = timerNUM2 + 1 : vie = vie +1 creepsMAXold = creepsMAX : creepsMAX = creepsMAX + 30 : if creepsMAX > creeps then creepsMAX = creeps for c = (creepsMAXold+1) to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) case 2 creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) case 3 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) case 4 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) end select next end if call Sleep 1 : goto [endLEVEL]
[close] timer 0 : close #main : end
[directionSPRITES] direction = int(rnd(1)*4+1) : jump = rnd(1)*0.04+0.02 select case direction case 1 if creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + jump case 2 if creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - jump case 3 if creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + jump case 4 if creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - jump end select return
'------------------------ FONCTIONS ------------------------------------------------------------------------------------------------------
function GetAsyncKeyState(key) calldll #user32, "GetAsyncKeyState",key as long,GetAsyncKeyState as long if GetAsyncKeyState<>0 then GetAsyncKeyState=1 end function
sub readJStick n if GetAsyncKeyState(_VK_ESCAPE) then dx = 2 if GetAsyncKeyState(asc("Z")) or GetAsyncKeyState(_VK_UP) then dy = -1 if GetAsyncKeyState(asc("W")) or GetAsyncKeyState(_VK_UP) then dy = -1 if GetAsyncKeyState(asc("S")) or GetAsyncKeyState(_VK_DOWN) then dy = 1 if GetAsyncKeyState(asc("Q")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 if GetAsyncKeyState(asc("A")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 if GetAsyncKeyState(asc("D")) or GetAsyncKeyState(_VK_RIGHT) then dx = 1 end sub
sub removeSprites list$ while 1 i=i+1 spr$=word$(list$, i) if spr$ = "" then exit while print #main.map,"removesprite ";spr$ wend end sub
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
function fileExist(dir$,file$) dim info$(10, 10) files dir$,file$, info$( if val(info$(0, 0)) > 0 then fileExist = 1 else fileExist = 0 end if end function
'------------------------ SYSTEME DE SAUVEGARDE ET CHARGEMENT DES DONNEES DU JEU ------------------------------------------------------------------------------------------------------
[file] pass$ = "0" : save = 0 : perso1x = 19 : perso1y = 32 : valIniX = perso1x-10 : valIniY = perso1y-6 gosub [print] : goto [start] [print] open "data.txt" for output as #secu print #secu, pass$ print #secu, save print #secu, perso1x print #secu, perso1y print #secu, valIniX print #secu, valIniY print #secu, vie print #secu, creeps print #secu, creepsMAX print #secu, timerNUM2 close #secu return
[input] open "data.txt" for input as #secu input #secu, pass$ input #secu, save input #secu, perso1x input #secu, perso1y input #secu, valIniX input #secu, valIniY input #secu, vie input #secu, creeps input #secu, creepsMAX input #secu, timerNUM2 close #secu return
|
|
|
Post by dan1101 on Jan 1, 2023 12:57:25 GMT -5
Excellent display of survival countdown and lives remaining now. Zero flicker. Very nice.
The shorter duration of three minutes is much more reasonable. Good choice.
The new monster AI has an interesting effect. In the original version it was easy to avoid the monsters by simply running around the outside edge of the room continuously. The monsters never caught up. In the newer version, the monsters are far faster and more aggressive. They swarm around the player so quickly that survival for more than about 30 seconds is all but impossible while moving about the room. However, I found a simple strategy that makes survival easy again. Since the new AI has the monsters stop following the player when they move out of the field of view, all the player has to do is move to one of the far corners of the room, and then STOP MOVING. All the monsters in the view at that time will attack, reducing the players lives, but after that group is gone, almost no new monsters will appear, because there are none in sight. The player can stand there alone and let the timer tick down, losing only a handful of lives when a monster happens to randomly wander into the field of view. By standing still in the corner, it is easy to survive the 3 minutes.
There is something glitchy about the timer. Since there is no victory condition, if you make it to three minutes, the timer simply keeps going, continuing to subtract a minute each time the seconds reach zero. This means that the minutes move on into negative numbers. I have made it as far as negative seven minutes on the clock before using up all fifty of my lives.
I think the next stage in development could include adding a goal in addition to survival, such as looking for a treasure, a power-up to restore lives, or an exit. The ladder at the top could be made to lead to another room of a different shape or size.
The game is getting better. Thanks again for sharing your hard work.
|
|
|
Post by atomose on Jan 1, 2023 17:18:14 GMT -5
hi dan1101! thanks for testing my game  ! Regarding the victory condition indeed I have not set it yet so the timer will go into the negative ... I will put a notification that the time is up and that the player has won ^^. For your strategy it's original but not flawless. Indeed, the monsters are moving all the time so even if you stay still in a corner you have a chance of losing the game even if it's a bet between the timer and the speed at which you lose your lives ^^ . I will continue to improve the concept but it will only remain a concept because it is a very light version of my future game "Survival Re-Evolution" on my website. So I can't put too much content here for a free and open source version. Nevertheless, I want to give a stable and complete version (in its basic version) so I will still polish this code. Thank you again for taking the time to test, if you want there are other games of mine that I share (tower defense, open world rpg, raytracer ... etc). EDIT : Small update that fixes the timer that no longer goes into the negative and modification of the AI that will find you ... even in the corners ;P
EDIT 2 : A other update with correct reload values for saved game and somes optimisations on the code 
|
|
|
Post by atomose on Jan 5, 2023 6:05:13 GMT -5
a new update that adds an interesting option to ai. indeed, the more you remain static, the more the detection zone of the latter widens. so you can't hide anymore 
'*********************************************************** ' Official website : www.atomose.fr ' ' LibertyBasic 4.51 pro licence ' ' By Alexandre Lomuto (Atomose Studio) ' '***********************************************************
nomainwin
'------------------------ CHARGEMENT DES VARIABLES DU JEU ( CARTE ET UNITEES ) ------------------------------------------------------------------------------------------------------
[ini] dir$ = "" : file$ = "data.txt" if fileExist(dir$,file$) = 0 then gosub [print] : goto [start] gosub [input] if pass$ = "1" then end pass$ = "1" if save = 1 then goto [loaded]
[start] perso1x = 19 : perso1y = 12 : valIniX = 9 : valIniY = 6 : vie = 50 : FINALtimer = 2 : timerNUM = 0 global creepsMAX, vie, creepsMAXold, noMOOVE creepsMAX = 40 : vie = 50 : creepsMAXold = 0 : noMOOVE = 0
[loaded] pers$="perso1" sprites$ = "echelle cache creepA perso1 perso1b perso1c perso1d perso2 perso2b perso2c perso2d perso3 perso3b perso3c perso3d perso4 perso4b perso4c perso4d mur terre mur2 mur3 mur4 mur5 mur6 mur7 mur8 mur9" for s = 1 to 29 loadbmp word$(sprites$,s), "data\"+word$(sprites$,s)+".bmp" next
dim p(x,y) : global dy,dx WindowWidth = 302 : WindowHeight = 602 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) x= 40 : y= 25
graphicbox #main.map, 0, 0, WindowWidth, WindowHeight open "Survival" for window_popup as #main #main.map, "down; fill black; color black; backcolor black"
[map] redim p(x,y) data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,08,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,10,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,09,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,11,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 restore [map]
for b=0 to y-1 for a=0 to x-1 read valeur : p(a,b)= valeur next a next b
'------------------------ CHARGEMENTS DE TEXTURES DU JEU ------------------------------------------------------------------------------------------------------
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main2.map, 2, 2, WindowWidth-5, WindowHeight-4 open "Survival" for window_popup as #main2 #main2.map, "setfocus; down; fill black; font ink_free Roman 30; color yellow; backcolor black" #main2.map, "place 330 400 ;\"; "Chargement des données du monde ..."
num1 = 0 : maxx= 40 : maxy= 30 for i = 0 to 7 for j = 0 to 4 num1 = 0 for y=0 to 4 for x= 0 to 4 num1 = num1 +1 sprName$="spr";num1 select case p(x+i*5,y+j*5) case 0 print #main.map,"addsprite ";sprName$;" terre" case 2 print #main.map,"addsprite ";sprName$;" mur2" case 4 print #main.map,"addsprite ";sprName$;" mur3" case 3 print #main.map,"addsprite ";sprName$;" mur" case 6 print #main.map,"addsprite ";sprName$;" mur5" case 7 print #main.map,"addsprite ";sprName$;" mur4" case 8 print #main.map,"addsprite ";sprName$;" mur6" case 9 print #main.map,"addsprite ";sprName$;" mur9" case 10 print #main.map,"addsprite ";sprName$;" mur7" case 11 ' print #main.map,"addsprite ";sprName$;" mur8" end select #main.map,"spritexy ";sprName$;" ";(x)*60;" ";300+(y)*60 'at 0, 300 next next
#main.map "drawsprites" #main.map "place 0 0; boxfilled 300 300 " bmp$="bg";right$(str$(100+i), 2);right$(str$(100+j), 2) #main.map "getbmp ";bmp$;" 0 0 300 600"
for k = 1 to num1 sprName$="spr";k print #main.map,"removesprite ";sprName$ next next next
valIniXold = valIniX : valIniYold = valIniY : valX = 0 : valY = 0 : num1 = 0 close #main : close #main2
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main.map, 0, _WS_BORDER, 0, 0 stylebits #main.map2, 0, _WS_BORDER, 0, 0
graphicbox #main.map, 3, 30, WindowWidth-6, WindowHeight-33 graphicbox #main.map2, 3, 3, WindowWidth-6, 27 open "Survival" for window_popup as #main #main, "trapclose [close]" #main.map, "setfocus; down; fill ";20;" ";20;" ";20 #main.map2, "down; fill ";20;" ";20;" ";20 #main.map2, "font ink_free Roman 12; color white"
'------------------------ CHARGEMENT DES PERSONNAGES ------------------------------------------------------------------------------------------------------
print #main.map,"addsprite perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d" print #main.map,"addsprite perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d" print #main.map,"addsprite perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d" print #main.map,"addsprite perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d"
global creeps, perso1x, perso1y, valIniX, valIniY, creepsMAX, timerNUM2, scale creeps = 100 dim creepPosX(creeps) dim creepPosY(creeps)
for c = 1 to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) if RNDzones = 1 then creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 2 then creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 3 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) if RNDzones = 4 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) next c
print #main.map, "addsprite cache cache; spritexy cache 0 0" print #main.map, "addsprite echelle echelle echelle"
'------------------------ BOUCLE PRINCIPALE DU JEU ------------------------------------------------------------------------------------------------------
[endLEVEL] if int(60-(timerNUM/62)) >= 0 and int(FINALtimer - timerNUM2) > -1 then #main.map2, "backcolor ";20;" ";20;" ";20;"; color green ;font ink_free Roman 14 bold; place 500 25;\"; "Survivre ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" " #main.map2, "backcolor ";20;" ";20;" ";20;"; color red; place 680 25;\"; "Vies : "; vie; " "
bgList$ = "" for i = 0 to 7 for j = 0 to 4 realX=(i*5-valIniX)*60 : realY=(j*5-valIniY)*60 if realX >= 0-298 and realX < WindowWidth-7 and realY >= 0-298 and realY < WindowHeight-6 then bmp$="bg";right$(str$(1000+i), 2);right$(str$(1000+j), 2) #main.map,"addsprite ";bmp$; " ";bmp$;"; spritexy ";bmp$; " " ;realX;" ";realY bgList$ = bgList$+" "+bmp$ end if next next
dy = 0 : dx = 0 : scale = 0.05 call readJStick 1
if dx = 2 and timerNUM >10 then confirm "Voulez vous quitter le jeu ?";quit$ if quit$ = "yes" then pass$ = "0" : save = 1 : gosub [print] : timer 0 : close #main : end dx = 0 end if
if dy <> 0 then dx = 0 valIniX = valIniX+(1*dx)*scale : perso1x = perso1x +(1*dx)*scale : valIniY = valIniY+(1*dy)*scale : perso1y = perso1y +(1*dy)*scale
select case p(INT(perso1x+0.5),INT(perso1y+0.55)) case 0 select case dx case 1 perso = 2 : pers$="perso3" case -1 perso = 1 : pers$="perso2" end select select case dy case 1 perso = 3 : pers$="perso1" case -1 perso = 4 : pers$="perso4" end select case else select case dx case 1 valIniX = valIniX -1*scale : perso1x = perso1x -1*scale : pers$="perso3" case -1 valIniX = valIniX +1*scale : perso1x = perso1x +1*scale : pers$="perso2" end select select case dy case 1 valIniY = valIniY -1*scale : perso1y = perso1y -1*scale : pers$="perso1" case -1 valIniY = valIniY +1*scale : perso1y = perso1y +1*scale : pers$="perso4" end select end select
'--------------- SPRITES GESTION ---------------- for thisCreep = 1 to creepsMAX DistanceSprite = 4 + int(noMOOVE/100) dist = sqr(abs(perso1x-creepPosX(thisCreep))*abs(perso1x-creepPosX(thisCreep)) + abs(perso1y-creepPosY(thisCreep))*abs(perso1y-creepPosY(thisCreep))) if dist <= DistanceSprite then if int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60) then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.030 if int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)+20 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.030 if int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60) then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.024 if int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)+20 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.024 gosub [directionSPRITES] '--re-creation-sprite----- if (int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)-10 and int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60)+40) AND (int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)-30 and int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60)+20) then vie = vie - 1 : if vie <= 0 then notice " " + chr$(13) + "GAME OVER ... let's try again !" : vie = 50 : timerNUM2 = 0 : timerNUM = 0 RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(thisCreep) = (rnd(1)*2+10) : creepPosY(thisCreep) = (rnd(1)*12+7) case 2 creepPosX(thisCreep) = (rnd(1)*2+27) : creepPosY(thisCreep) = (rnd(1)*12+7) case 3 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+6.5) case 4 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+17.5) end select end if end if if dist > DistanceSprite then choix = int(rnd(1)*4+1) if choix = 1 and creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.10 if choix = 2 and creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.10 if choix = 3 and creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.10 if choix = 4 and creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.10 gosub [directionSPRITES] end if #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10);"; spritetofront creepA";thisCreep '--------------- next '----------------------------------------------
print #main.map, "spritexy echelle ";int((20-valIniX)*60);" ";int((5-valIniY)*60)-10;"; spritetofront echelle" print #main.map, "SpriteVisible cache on; spritetofront cache" print #main.map, "spritexy ";pers$;" ";int((WindowWidth/2)-30);" ";int((WindowHeight/2)-30);"; SpriteVisible ";pers$;" on; spritetofront ";pers$ if dx<>0 or dy<>0 then #main.map, "cyclesprite ";pers$;" 1 once" #main.map "drawsprites"
call removeSprites bgList$ print #main.map, "SpriteVisible ";pers$;" off" timerNUM = timerNUM + 1 if timerNUM >=3720 then timerNUM = 1 : timerNUM2 = timerNUM2 + 1 : vie = vie +1 creepsMAXold = creepsMAX : creepsMAX = creepsMAX + 30 : if creepsMAX > creeps then creepsMAX = creeps for c = (creepsMAXold+1) to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) case 2 creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) case 3 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) case 4 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) end select next end if noMOOVE = noMOOVE +1 #main.map, "discard" call Sleep 1 : goto [endLEVEL]
[close] timer 0 : close #main : end
[directionSPRITES] direction = int(rnd(1)*4+1) : jump = rnd(1)*0.04+0.02 select case direction case 1 if creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + jump case 2 if creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - jump case 3 if creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + jump case 4 if creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - jump end select return
'------------------------ FONCTIONS ------------------------------------------------------------------------------------------------------
function GetAsyncKeyState(key) calldll #user32, "GetAsyncKeyState",key as long,GetAsyncKeyState as long if GetAsyncKeyState<>0 then GetAsyncKeyState=1 end function
sub readJStick n if GetAsyncKeyState(_VK_ESCAPE) then dx = 2 if GetAsyncKeyState(asc("Z")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("W")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("S")) or GetAsyncKeyState(_VK_DOWN) then dy = 1 : noMOOVE = 0 if GetAsyncKeyState(asc("Q")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("A")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("D")) or GetAsyncKeyState(_VK_RIGHT) then dx = 1 : noMOOVE = 0 end sub
sub removeSprites list$ while 1 i=i+1 spr$=word$(list$, i) if spr$ = "" then exit while print #main.map,"removesprite ";spr$ wend end sub
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
function fileExist(dir$,file$) dim info$(10, 10) files dir$,file$, info$( if val(info$(0, 0)) > 0 then fileExist = 1 else fileExist = 0 end if end function
'------------------------ SYSTEME DE SAUVEGARDE ET CHARGEMENT DES DONNEES DU JEU ------------------------------------------------------------------------------------------------------
[print] open "data.txt" for output as #secu print #secu, pass$ print #secu, save print #secu, perso1x print #secu, perso1y print #secu, valIniX print #secu, valIniY print #secu, vie print #secu, creeps print #secu, creepsMAX print #secu, timerNUM2 print #secu, FINALtimer print #secu, timerNUM close #secu return
[input] open "data.txt" for input as #secu input #secu, pass$ input #secu, save input #secu, perso1x input #secu, perso1y input #secu, valIniX input #secu, valIniY input #secu, vie input #secu, creeps input #secu, creepsMAX input #secu, timerNUM2 input #secu, FINALtimer input #secu, timerNUM close #secu return
|
|
|
Post by dan1101 on Jan 7, 2023 6:36:13 GMT -5
The game continues to improve with each release. In Version 0.84 it is a bit more difficult to use the corner strategy, but it still works with only slightly more effort. Rather than move to a corner and remain still, all that is necessary is to move to a corner and shift position slightly every couple seconds. By staying in the corner and moving left and right by a single step, the new AI is not triggered, so you can still remain mostly undetected and survive. I still think the program could be made even better by including more goals than merely survival. Provide some randomly scattered prizes to encourage exploration. Also, there are far too many monsters to survive for more than a few seconds in the open. Possibly reduce the number of monsters to give the player a fighting chance. Otherwise, moving around is always deadly within a few seconds. And because there are so many monsters and they move so fast, it is literally impossible to evade them. The game begins to feel hopeless if you always lose. And using the corner survival strategy is simply not very interesting. I think a better balance between the chance of survival and the risk of defeat would improve the game, along with some goals to achieve. Also, I would still like to see an acknowledgement of victory. When the player survives, all that happens is that the timer stops at zero and the game continues. Oh, and one more thing: I would love to see the ability to PAUSE the game, possibly by hitting the space bar during play? Thank you for sharing your progress. Here is a screenshot of my latest successful survival using the corner movement-shifting strategy. Note that only 15 monsters wandered randomly into the corner during the three minutes. 
|
|
|
Post by atomose on Jan 7, 2023 12:19:18 GMT -5
congratulations on surviving and thanks for testing my game ! As I mentioned above, this is mostly an open source program to show others how it's possible to make it. This version is very far from the pro version which includes a level up for the character, equipment, missions, different monsters, potions which appear on the ground to heal themselves and above all a character who moves in 8 dimensions and no 4 (which allows dodging and makes the game much more manageable). I will continue to improve this version but the pro version takes a lot of time ^^. EDIT : New version 0.87 with the possibility to stop the time (space key) and little bugs fixed 
'*********************************************************** ' Official website : www.atomose.fr ' ' LibertyBasic 4.51 pro licence ' ' By Alexandre Lomuto (Atomose Studio) ' '***********************************************************
nomainwin
'------------------------ CHARGEMENT DES VARIABLES DU JEU ( CARTE ET UNITEES ) ------------------------------------------------------------------------------------------------------
[ini] dir$ = "" : file$ = "data.txt" if fileExist(dir$,file$) = 0 then gosub [print] : goto [start] gosub [input] if pass$ = "1" then end pass$ = "1" if save = 1 then goto [loaded]
[start] perso1x = 19 : perso1y = 12 : valIniX = 9 : valIniY = 6 : vie = 50 : FINALtimer = 2 : timerNUM = 0 global creepsMAX, vie, creepsMAXold, noMOOVE creepsMAX = 40 : vie = 50 : creepsMAXold = 0 : noMOOVE = 0
[loaded] pers$="perso1" sprites$ = "echelle cache creepA perso1 perso1b perso1c perso1d perso2 perso2b perso2c perso2d perso3 perso3b perso3c perso3d perso4 perso4b perso4c perso4d mur terre mur2 mur3 mur4 mur5 mur6 mur7 mur8 mur9" for s = 1 to 29 loadbmp word$(sprites$,s), "data\"+word$(sprites$,s)+".bmp" next
dim p(x,y) : global dy,dx WindowWidth = 302 : WindowHeight = 602 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) x= 40 : y= 25
graphicbox #main.map, 0, 0, WindowWidth, WindowHeight open "Survival" for window_popup as #main #main.map, "down; fill black; color black; backcolor black"
[map] redim p(x,y) data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,08,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,10,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,09,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,11,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 restore [map]
for b=0 to y-1 for a=0 to x-1 read valeur : p(a,b)= valeur next a next b
'------------------------ CHARGEMENTS DE TEXTURES DU JEU ------------------------------------------------------------------------------------------------------
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main2.map, 2, 2, WindowWidth-5, WindowHeight-4 open "Survival" for window_popup as #main2 #main2.map, "setfocus; down; fill black; font ink_free Roman 30; color yellow; backcolor black" #main2.map, "place 330 400 ;\"; "Chargement des données du monde ..."
num1 = 0 : maxx= 40 : maxy= 30 for i = 0 to 7 for j = 0 to 4 num1 = 0 for y=0 to 4 for x= 0 to 4 num1 = num1 +1 sprName$="spr";num1 select case p(x+i*5,y+j*5) case 0 print #main.map,"addsprite ";sprName$;" terre" case 2 print #main.map,"addsprite ";sprName$;" mur2" case 4 print #main.map,"addsprite ";sprName$;" mur3" case 3 print #main.map,"addsprite ";sprName$;" mur" case 6 print #main.map,"addsprite ";sprName$;" mur5" case 7 print #main.map,"addsprite ";sprName$;" mur4" case 8 print #main.map,"addsprite ";sprName$;" mur6" case 9 print #main.map,"addsprite ";sprName$;" mur9" case 10 print #main.map,"addsprite ";sprName$;" mur7" case 11 ' print #main.map,"addsprite ";sprName$;" mur8" end select #main.map,"spritexy ";sprName$;" ";(x)*60;" ";300+(y)*60 'at 0, 300 next next
#main.map "drawsprites" #main.map "place 0 0; boxfilled 300 300 " bmp$="bg";right$(str$(100+i), 2);right$(str$(100+j), 2) #main.map "getbmp ";bmp$;" 0 0 300 600"
for k = 1 to num1 sprName$="spr";k print #main.map,"removesprite ";sprName$ next next next
valIniXold = valIniX : valIniYold = valIniY : valX = 0 : valY = 0 : num1 = 0 close #main : close #main2
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main.map, 0, _WS_BORDER, 0, 0 stylebits #main.map2, 0, _WS_BORDER, 0, 0
graphicbox #main.map, 3, 30, WindowWidth-6, WindowHeight-33 graphicbox #main.map2, 3, 3, WindowWidth-6, 27 open "Survival" for window_popup as #main #main, "trapclose [close]" #main.map, "setfocus; down; fill ";20;" ";20;" ";20 #main.map2, "down; fill ";20;" ";20;" ";20 #main.map2, "font ink_free Roman 12; color white" #main.map, "when leftButtonDown [endLEVEL]"
'------------------------ CHARGEMENT DES PERSONNAGES ------------------------------------------------------------------------------------------------------
'print #main.map,"spriteimage perso3 perso3" print #main.map,"addsprite perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d" print #main.map,"addsprite perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d" print #main.map,"addsprite perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d" print #main.map,"addsprite perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d"
global creeps, perso1x, perso1y, valIniX, valIniY, creepsMAX, timerNUM2, scale creeps = 100 dim creepPosX(creeps) dim creepPosY(creeps)
for c = 1 to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) if RNDzones = 1 then creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 2 then creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 3 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) if RNDzones = 4 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) next c
print #main.map, "addsprite cache cache; spritexy cache 0 0" print #main.map, "addsprite echelle echelle echelle"
'------------------------ BOUCLE PRINCIPALE DU JEU ------------------------------------------------------------------------------------------------------
[endLEVEL] #main.map2, "discard" if int(60-(timerNUM/62)) >= 0 and int(FINALtimer - timerNUM2) > -1 then #main.map2, "backcolor ";20;" ";20;" ";20;"; color green ;font ink_free Roman 14 bold; place 500 25;\"; "Survive ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" " #main.map2, "backcolor ";20;" ";20;" ";20;"; color red; place 680 25;\"; "life : "; vie; " "
bgList$ = "" for i = 0 to 7 for j = 0 to 4 realX=(i*5-valIniX)*60 : realY=(j*5-valIniY)*60 if realX >= 0-298 and realX < WindowWidth-7 and realY >= 0-298 and realY < WindowHeight-6 then bmp$="bg";right$(str$(1000+i), 2);right$(str$(1000+j), 2) #main.map,"addsprite ";bmp$; " ";bmp$;"; spritexy ";bmp$; " " ;realX;" ";realY bgList$ = bgList$+" "+bmp$ end if next next
dy = 0 : dx = 0 : scale = 0.05 call readJStick 1
if dx = 2 and timerNUM >100 then confirm "Voulez vous quitter le jeu ?";quit$ if quit$ = "yes" then pass$ = "0" : save = 1 : gosub [print] : timer 0 : close #main : end dx = 0 end if
if secuPAUSE = 1 then #main.map2, "place 410 25;\"; " " secuPAUSE = 0 if dx = 3 and timerNUM >100 then secuPAUSE = secuPAUSE + 1 if secuPAUSE = 1 then #main.map2, "place 410 25;\"; "GAME PAUSED (click on the map for stop pause) " : wait end if
if dy <> 0 then dx = 0 valIniX = valIniX+(1*dx)*scale : perso1x = perso1x +(1*dx)*scale : valIniY = valIniY+(1*dy)*scale : perso1y = perso1y +(1*dy)*scale
select case p(INT(perso1x+0.5),INT(perso1y+0.55)) case 0 select case dx case 1 pers$="perso3" case -1 pers$="perso2" end select select case dy case 1 pers$="perso1" case -1 pers$="perso4" end select case else select case dx case 1 valIniX = valIniX -1*scale : perso1x = perso1x -1*scale : pers$="perso3" case -1 valIniX = valIniX +1*scale : perso1x = perso1x +1*scale : pers$="perso2" end select select case dy case 1 valIniY = valIniY -1*scale : perso1y = perso1y -1*scale : pers$="perso1" case -1 valIniY = valIniY +1*scale : perso1y = perso1y +1*scale : pers$="perso4" end select end select
'--------------- SPRITES GESTION ---------------- for thisCreep = 1 to creepsMAX DistanceSprite = 4 + int(noMOOVE/100) dist = sqr(abs(perso1x-creepPosX(thisCreep))*abs(perso1x-creepPosX(thisCreep)) + abs(perso1y-creepPosY(thisCreep))*abs(perso1y-creepPosY(thisCreep))) if dist <= DistanceSprite then if int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60) then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.030 if int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)+20 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.030 if int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60) then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.024 if int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)+20 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.024 gosub [directionSPRITES] '--re-creation-sprite----- if (int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)-10 and int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60)+40) AND (int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)-30 and int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60)+20) then vie = vie - 1 : if vie <= 0 then notice " " + chr$(13) + "GAME OVER ... let's try again !" : vie = 50 : timerNUM2 = 0 : timerNUM = 0 RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(thisCreep) = (rnd(1)*2+10) : creepPosY(thisCreep) = (rnd(1)*12+7) case 2 creepPosX(thisCreep) = (rnd(1)*2+27) : creepPosY(thisCreep) = (rnd(1)*12+7) case 3 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+6.5) case 4 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+17.5) end select end if end if if dist > DistanceSprite then choix = int(rnd(1)*4+1) if choix = 1 and creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.10 if choix = 2 and creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.10 if choix = 3 and creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.10 if choix = 4 and creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.10 gosub [directionSPRITES] end if #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10);"; spritetofront creepA";thisCreep '--------------- next '----------------------------------------------
print #main.map, "spritexy echelle ";int((20-valIniX)*60);" ";int((5-valIniY)*60)-10;"; spritetofront echelle" print #main.map, "SpriteVisible cache on; spritetofront cache" print #main.map, "spritexy ";pers$;" ";int((WindowWidth/2)-30);" ";int((WindowHeight/2)-30);"; SpriteVisible ";pers$;" on; spritetofront ";pers$ if dx<>0 or dy<>0 then #main.map, "cyclesprite ";pers$;" 1 once" #main.map "drawsprites"
call removeSprites bgList$ print #main.map, "SpriteVisible ";pers$;" off" timerNUM = timerNUM + 1 if timerNUM >=3720 then timerNUM = 1 : timerNUM2 = timerNUM2 + 1 : vie = vie +1 creepsMAXold = creepsMAX : creepsMAX = creepsMAX + 30 : if creepsMAX > creeps then creepsMAX = creeps for c = (creepsMAXold+1) to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) case 2 creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) case 3 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) case 4 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) end select next end if noMOOVE = noMOOVE +1 #main.map, "discard" call Sleep 1 : goto [endLEVEL]
[close] timer 0 : close #main : end
[directionSPRITES] direction = int(rnd(1)*4+1) : jump = rnd(1)*0.04+0.02 select case direction case 1 if creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + jump case 2 if creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - jump case 3 if creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + jump case 4 if creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - jump end select return
'------------------------ FONCTIONS ------------------------------------------------------------------------------------------------------
function GetAsyncKeyState(key) calldll #user32, "GetAsyncKeyState",key as long,GetAsyncKeyState as long if GetAsyncKeyState<>0 then GetAsyncKeyState=1 end function
sub readJStick n if GetAsyncKeyState(_VK_ESCAPE) then dx = 2 if GetAsyncKeyState(_VK_SPACE) then dx = 3 if GetAsyncKeyState(asc("Z")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("W")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("S")) or GetAsyncKeyState(_VK_DOWN) then dy = 1 : noMOOVE = 0 if GetAsyncKeyState(asc("Q")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("A")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("D")) or GetAsyncKeyState(_VK_RIGHT) then dx = 1 : noMOOVE = 0 end sub
sub removeSprites list$ while 1 i=i+1 spr$=word$(list$, i) if spr$ = "" then exit while print #main.map,"removesprite ";spr$ wend end sub
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
function fileExist(dir$,file$) dim info$(10, 10) files dir$,file$, info$( if val(info$(0, 0)) > 0 then fileExist = 1 else fileExist = 0 end if end function
'------------------------ SYSTEME DE SAUVEGARDE ET CHARGEMENT DES DONNEES DU JEU ------------------------------------------------------------------------------------------------------
[print] open "data.txt" for output as #secu print #secu, pass$ print #secu, save print #secu, perso1x print #secu, perso1y print #secu, valIniX print #secu, valIniY print #secu, vie print #secu, creeps print #secu, creepsMAX print #secu, timerNUM2 print #secu, FINALtimer print #secu, timerNUM close #secu return
[input] open "data.txt" for input as #secu input #secu, pass$ input #secu, save input #secu, perso1x input #secu, perso1y input #secu, valIniX input #secu, valIniY input #secu, vie input #secu, creeps input #secu, creepsMAX input #secu, timerNUM2 input #secu, FINALtimer input #secu, timerNUM close #secu return
|
|
|
Post by tsh73 on Jan 7, 2023 15:37:53 GMT -5
Hello Alexandre Was really surprised as to why this code does not work in Windows XP Happened that in Windows XP, GETBMP needs window actually VISIBLE (that is, obscuring it with another window saying "Data loading" does not work - all tiles end up black/with that yellow incription) Though it works in Win 7 and Win 10.
Also - really nice icon in your EXE.
Also looked through code, found this line
font ink_free Roman 14 bold Does "Roman" do something? I think it is not supposed to be there and just silently ignored.
|
|
|
Post by atomose on Jan 7, 2023 15:49:32 GMT -5
Well in fact no its just the full font name ^^. Its working with just ink_free. If you have a bug with this font you can remoove it  . (i work on w10-w11 so i cant see all bugs ^^) thx for report 
|
|
|
Post by atomose on Feb 16, 2023 4:00:15 GMT -5
New upgrade with ...
- 8 directions for run ! - life regeneration ! - more sprites, more fun !  here is the code, if you need files its on the first post 
'*********************************************************** ' Official website : www.atomose.fr ' ' LibertyBasic 4.51 pro licence ' ' By Alexandre Lomuto (Atomose Studio) ' '***********************************************************
nomainwin
'------------------------ CHARGEMENT DES VARIABLES DU JEU ( CARTE ET UNITEES ) ------------------------------------------------------------------------------------------------------
[ini] dir$ = "" : file$ = "data.txt" if fileExist(dir$,file$) = 0 then gosub [print] : goto [start] gosub [input] if pass$ = "1" then end pass$ = "1" if save = 1 then goto [loaded]
[start] perso1x = 19 : perso1y = 12 : valIniX = 9 : valIniY = 6 : vie = 50 : FINALtimer = 2 : timerNUM = 0 global creepsMAX, vie, creepsMAXold, noMOOVE creepsMAX = 50 : vie = 50 : creepsMAXold = 0 : noMOOVE = 0
[loaded] pers$="perso1" sprites$ = "cache creepA perso1 perso1b perso1c perso1d perso2 perso2b perso2c perso2d perso3 perso3b perso3c perso3d perso4 perso4b perso4c perso4d mur terre mur2 mur3 mur4 mur5 mur6 mur7 mur8 mur9" for s = 1 to 28 loadbmp word$(sprites$,s), "data\"+word$(sprites$,s)+".bmp" next
dim p(x,y) : global dy,dx WindowWidth = 302 : WindowHeight = 602 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) x= 40 : y= 25
graphicbox #main.map, 0, 0, WindowWidth, WindowHeight open "Survival" for window_popup as #main #main.map, "down; fill black; color black; backcolor black"
[map] redim p(x,y) data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,08,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,10,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,07,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,09,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,04,11,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 data 03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03,03 restore [map]
for b=0 to y-1 for a=0 to x-1 read valeur : p(a,b)= valeur next a next b
'------------------------ CHARGEMENTS DE TEXTURES DU JEU ------------------------------------------------------------------------------------------------------
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main2.map, 2, 2, WindowWidth-5, WindowHeight-4 open "Survival" for window_popup as #main2 #main2.map, "setfocus; down; fill black; font ink_free 30; color yellow; backcolor black" #main2.map, "place 330 400 ;\"; "Chargement des données du monde ..."
num1 = 0 for i = 0 to 7 for j = 0 to 4 num1 = 0 for y=0 to 4 for x= 0 to 4 num1 = num1 +1 sprName$="spr";num1 select case p(x+i*5,y+j*5) case 0 print #main.map,"addsprite ";sprName$;" terre" case 2 print #main.map,"addsprite ";sprName$;" mur2" case 4 print #main.map,"addsprite ";sprName$;" mur3" case 3 print #main.map,"addsprite ";sprName$;" mur" case 6 print #main.map,"addsprite ";sprName$;" mur5" case 7 print #main.map,"addsprite ";sprName$;" mur4" case 8 print #main.map,"addsprite ";sprName$;" mur6" case 9 print #main.map,"addsprite ";sprName$;" mur9" case 10 print #main.map,"addsprite ";sprName$;" mur7" case 11 ' print #main.map,"addsprite ";sprName$;" mur8" end select #main.map,"spritexy ";sprName$;" ";(x)*60;" ";300+(y)*60 next next
#main.map "drawsprites" #main.map "place 0 0; boxfilled 300 300 " bmp$="bg";right$(str$(100+i), 2);right$(str$(100+j), 2) #main.map "getbmp ";bmp$;" 0 0 300 600"
for k = 1 to num1 sprName$="spr";k print #main.map,"removesprite ";sprName$ next next next
valIniXold = valIniX : valIniYold = valIniY : valX = 0 : valY = 0 : num1 = 0 close #main : close #main2
WindowWidth = 1267 : WindowHeight = 743 : UpperLeftX=int((DisplayWidth-WindowWidth)/2) : UpperLeftY=int((DisplayHeight-WindowHeight)/2)
stylebits #main.map, 0, _WS_BORDER, 0, 0 stylebits #main.map2, 0, _WS_BORDER, 0, 0
graphicbox #main.map, 3, 30, WindowWidth-6, WindowHeight-33 graphicbox #main.map2, 3, 3, WindowWidth-6, 27 open "Survival" for window_popup as #main #main, "trapclose [close]" #main.map, "setfocus; down; fill ";20;" ";20;" ";20 #main.map2, "down; fill ";20;" ";20;" ";20 #main.map2, "font ink_free 12; color white" #main.map, "when leftButtonDown [endLEVEL]"
'------------------------ CHARGEMENT DES PERSONNAGES ------------------------------------------------------------------------------------------------------
'print #main.map,"spriteimage perso3 perso3" print #main.map,"addsprite perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3 perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3b perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3c perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d perso3d" print #main.map,"addsprite perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2 perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2b perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2c perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d perso2d" print #main.map,"addsprite perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4 perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4b perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4c perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d perso4d" print #main.map,"addsprite perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1 perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1b perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1c perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d perso1d"
global creeps, perso1x, perso1y, valIniX, valIniY, creepsMAX, timerNUM2, scale creeps = 100 dim creepPosX(creeps) dim creepPosY(creeps)
for c = 1 to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) if RNDzones = 1 then creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 2 then creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) if RNDzones = 3 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) if RNDzones = 4 then creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) next c
print #main.map, "addsprite cache cache; spritexy cache 0 0"
'------------------------ BOUCLE PRINCIPALE DU JEU ------------------------------------------------------------------------------------------------------
[endLEVEL] #main.map2, "discard" if int(60-(timerNUM/62)) >= 0 and int(FINALtimer - timerNUM2) > -1 then #main.map2, "backcolor ";20;" ";20;" ";20;"; color green ;font ink_free 14 bold; place 500 25;\"; "Survive ";int(FINALtimer - timerNUM2) ; " : "; int(60-(timerNUM/62));" " #main.map2, "backcolor ";20;" ";20;" ";20;"; color red; place 680 25;\"; "life : "; vie; " "
bgList$ = "" for i = 0 to 7 for j = 0 to 4 realX=(i*5-valIniX)*60 : realY=(j*5-valIniY)*60 if realX >= 0-298 and realX < WindowWidth-7 and realY >= 0-298 and realY < WindowHeight-6 then bmp$="bg";right$(str$(1000+i), 2);right$(str$(1000+j), 2) #main.map,"addsprite ";bmp$; " ";bmp$;"; spritexy ";bmp$; " " ;realX;" ";realY bgList$ = bgList$+" "+bmp$ end if next next
dy = 0 : dx = 0 : scale = 0.05 call readJStick 1
if dx = 2 and timerNUM >10 then confirm "Voulez vous quitter le jeu ?";quit$ if quit$ = "yes" then pass$ = "0" : save = 1 : gosub [print] : timer 0 : close #main : end dx = 0 end if
if secuPAUSE = 1 then #main.map2, "place 410 25;\"; " " secuPAUSE = 0 if dx = 3 and timerNUM >10 then secuPAUSE = secuPAUSE + 1 if secuPAUSE = 1 then #main.map2, "place 410 25;\"; "GAME PAUSED (click on the map for stop pause) " : wait end if
scaleC = scale if (dy<> 0 and dx = 0) or (dx<> 0 and dy = 0) then Position$ = "" if dy = -1 and dx = 1 then scaleC = scale-0.01 : Position$ = "haut droit" if dy = -1 and dx = -1 then scaleC = scale-0.01 : Position$ = "haut gauche" if dy = 1 and dx = 1 then scaleC = scale-0.01 : Position$ = "bas droit" if dy = 1 and dx = -1 then scaleC = scale-0.01 : Position$ = "bas gauche" valIniX = valIniX+(1*dx)*scaleC : perso1x = perso1x +(1*dx)*scaleC : valIniY = valIniY+(1*dy)*scaleC : perso1y = perso1y +(1*dy)*scaleC
select case p(INT(perso1x+0.5),INT(perso1y+0.55)) case 0 select case dx case 1 if Position$ = "" then pers$="perso3" case -1 if Position$ = "" then pers$="perso2" end select select case dy case 1 if Position$ = "" then pers$="perso1" case -1 if Position$ = "" then pers$="perso4" end select case else select case dx case 1 valIniX = valIniX -1*scale : perso1x = perso1x -1*scale : pers$="perso3" case -1 valIniX = valIniX +1*scale : perso1x = perso1x +1*scale : pers$="perso2" end select select case dy case 1 valIniY = valIniY -1*scale : perso1y = perso1y -1*scale : pers$="perso1" case -1 valIniY = valIniY +1*scale : perso1y = perso1y +1*scale : pers$="perso4" end select end select
'--------------- SPRITES GESTION ---------------- for thisCreep = 1 to creepsMAX DistanceSprite = 5 + int(noMOOVE/100) dist = sqr(abs(perso1x-creepPosX(thisCreep))*abs(perso1x-creepPosX(thisCreep)) + abs(perso1y-creepPosY(thisCreep))*abs(perso1y-creepPosY(thisCreep))) if dist <= DistanceSprite then if int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60) then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.030 if int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)+20 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.030 if int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60) then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.024 if int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)+20 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.024 gosub [directionSPRITES] '--re-creation-sprite----- if (int((creepPosX(thisCreep)-valIniX)*60) > int((perso1x-valIniX)*60)-10 and int((creepPosX(thisCreep)-valIniX)*60) < int((perso1x-valIniX)*60)+40) AND (int((creepPosY(thisCreep)-valIniY)*60) > int((perso1y-valIniY)*60)-30 and int((creepPosY(thisCreep)-valIniY)*60) < int((perso1y-valIniY)*60)+20) then vie = vie - 1 : if vie <= 0 then notice " " + chr$(13) + "GAME OVER ... let's try again !" : vie = 50 : timerNUM2 = 0 : timerNUM = 0 RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(thisCreep) = (rnd(1)*2+10) : creepPosY(thisCreep) = (rnd(1)*12+7) case 2 creepPosX(thisCreep) = (rnd(1)*2+27) : creepPosY(thisCreep) = (rnd(1)*12+7) case 3 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+6.5) case 4 creepPosX(thisCreep) = (rnd(1)*19+10) : creepPosY(thisCreep) = (rnd(1)*1+17.5) end select end if end if if dist > DistanceSprite then choix = int(rnd(1)*4+1) if choix = 1 and creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + 0.10 if choix = 2 and creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - 0.10 if choix = 3 and creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + 0.10 if choix = 4 and creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - 0.10 end if gosub [directionSPRITES] #main.map,"spritexy creepA";thisCreep;" ";int(((creepPosX(thisCreep)-valIniX)*60)+10);" ";int(((creepPosY(thisCreep)-valIniY)*60)+10);"; spritetofront creepA";thisCreep '--------------- next '----------------------------------------------
print #main.map, "SpriteVisible cache on; spritetofront cache" print #main.map, "spritexy ";pers$;" ";int((WindowWidth/2)-30);" ";int((WindowHeight/2)-30);"; SpriteVisible ";pers$;" on; spritetofront ";pers$ if dx<>0 or dy<>0 then #main.map, "cyclesprite ";pers$;" 1 once" #main.map "drawsprites"
call removeSprites bgList$ print #main.map, "SpriteVisible ";pers$;" off" timerNUM = timerNUM + 1 : timerNUM3 = timerNUM3 + 1 if timerNUM3 >=62 and vie<100 then timerNUM3 = 0 : vie = vie + 1 if timerNUM >=3720 then timerNUM = 1 : timerNUM2 = timerNUM2 + 1 creepsMAXold = creepsMAX : creepsMAX = creepsMAX + 50 : if creepsMAX > creeps then creepsMAX = creeps for c = (creepsMAXold+1) to creepsMAX print #main.map,"addsprite creepA";c;" creepA" RNDzones = int(rnd(1)*4+1) select case RNDzones case 1 creepPosX(c) = (rnd(1)*2+10) : creepPosY(c) = (rnd(1)*12+7) case 2 creepPosX(c) = (rnd(1)*2+27) : creepPosY(c) = (rnd(1)*12+7) case 3 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+6.5) case 4 creepPosX(c) = (rnd(1)*19+10) : creepPosY(c) = (rnd(1)*1+17.5) end select next end if noMOOVE = noMOOVE +1 #main.map, "discard" call Sleep 1 : goto [endLEVEL]
[close] timer 0 : close #main : end
[directionSPRITES] direction = int(rnd(1)*4+1) : jump = rnd(1)*0.04+0.02 select case direction case 1 if creepPosX(thisCreep)<28 then creepPosX(thisCreep) = creepPosX(thisCreep) + jump case 2 if creepPosX(thisCreep)>11 then creepPosX(thisCreep) = creepPosX(thisCreep) - jump case 3 if creepPosY(thisCreep)<18 then creepPosY(thisCreep) = creepPosY(thisCreep) + jump case 4 if creepPosY(thisCreep)>7 then creepPosY(thisCreep) = creepPosY(thisCreep) - jump end select return
'------------------------ FONCTIONS ------------------------------------------------------------------------------------------------------
function GetAsyncKeyState(key) calldll #user32, "GetAsyncKeyState",key as long,GetAsyncKeyState as long if GetAsyncKeyState<>0 then GetAsyncKeyState=1 end function
sub readJStick n if GetAsyncKeyState(_VK_ESCAPE) then dx = 2 if GetAsyncKeyState(_VK_SPACE) then dx = 3 if GetAsyncKeyState(asc("Z")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("W")) or GetAsyncKeyState(_VK_UP) then dy = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("S")) or GetAsyncKeyState(_VK_DOWN) then dy = 1 : noMOOVE = 0 if GetAsyncKeyState(asc("Q")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("A")) or GetAsyncKeyState(_VK_LEFT) then dx = -1 : noMOOVE = 0 if GetAsyncKeyState(asc("D")) or GetAsyncKeyState(_VK_RIGHT) then dx = 1 : noMOOVE = 0 end sub
sub removeSprites list$ while 1 i=i+1 spr$=word$(list$, i) if spr$ = "" then exit while print #main.map,"removesprite ";spr$ wend end sub
Sub Sleep ms CallDLL #kernel32, "Sleep",_ ms as long,_ ret as void End Sub
function fileExist(dir$,file$) dim info$(10, 10) files dir$,file$, info$( if val(info$(0, 0)) > 0 then fileExist = 1 else fileExist = 0 end if end function
'------------------------ SYSTEME DE SAUVEGARDE ET CHARGEMENT DES DONNEES DU JEU ------------------------------------------------------------------------------------------------------
[print] open "data.txt" for output as #secu print #secu, pass$ print #secu, save print #secu, perso1x print #secu, perso1y print #secu, valIniX print #secu, valIniY print #secu, vie print #secu, creeps print #secu, creepsMAX print #secu, timerNUM2 print #secu, FINALtimer print #secu, timerNUM close #secu return
[input] open "data.txt" for input as #secu input #secu, pass$ input #secu, save input #secu, perso1x input #secu, perso1y input #secu, valIniX input #secu, valIniY input #secu, vie input #secu, creeps input #secu, creepsMAX input #secu, timerNUM2 input #secu, FINALtimer input #secu, timerNUM close #secu return
|
|