News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Happy Diver 2.0

Started by Sigtrygg, January 11, 2013, 03:13:59 PM

Previous topic - Next topic

Sigtrygg

Hello  community!

Thank you for comments and impoving examples.
I will try your suggestions, Mick! Thanks!
@Kevin: OK! I do understand: Never ever....  ;)
To change this, can't be very difficult, I think.
First setting resolution. Then loading media...
@bmorris: Yes! I agree with you, that the water should
be more living, but I didn't find any underwater-backgrounds
and I can't draw it by myself, because I am not an artist.
It would be fine, if I could use "Kevin's" Sinus-waves, but
I think I have to spent a lot of time to understand and
implement it.
I think to get the right media for your game is one of the
most great problems. I used some free gifs and splitted them
by "Gif-splitter", so I could use them for spriteimages.
Some of the fishes I drew by myself and you can see it!  ;)
Nevertheless I had a lot of fun when I made the game
and I will work further at HappyDiver and HellEagle.

Have a nice weekend!

Sigtrygg




Sigtrygg

I am working to implement moving the diver a liitle bit further when leaving Space-key
and that some breathing bubbles come from diver.

I will post one version with resolution 1024x768. I hope so, that anybody can play
that game without system-crash because of loaded media and changing resolution.

On my systems and the PCs of my friends changing resolution doesn't any matter,
but then you can choose which version is better to play.

Untill soon!

Sigtrygg

stevmjon

hey sigtrygg

  try making a menu screen to be loaded first, let the user choose the screen resolution, then load game graphics.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

Sigtrygg

Hello Stevmjon and all of community!

I tried it, but I would have had to reconifg a lot of code, because I am loading
media at different places.

So I post now a version with common resolution 1024x768.

I guess, now everybody can play that game.

I added diveracceleration and some bubbles. Good idea of Mick!

Please let me know, if this version run without chrashes.

Bye,

Sigtrygg

http://rghost.net/43238597

BlinkOk

luv it siggy dude. runs fine here.
nice work on the diver dude. i like the way he pops into nothing when he hits something.
for me i think i would prefer the up arrow to go forward rather than the space. but maybe that's just me

kevin

Sigtrygg,

    Haven't downloaded the update, but looking at the files in the previous version there does seem to be a lot of redundant media floating around.    In the level folder for example, you've got the original PNGs and the block map bmps.   The user doesn't need to be downloading the originals, so there's probably 4 or 5 meg saving off the bat.   Same with the music files, which seem to be encoded in higher bit rate than is needed.   Just re encoding them an OGG files at 128 will probably half the disc size and chop another 4 or 5 meg off the download size. 

BlinkOk

for mine i don't mind the size and i would also like the original images just in case i want to work with them

Sigtrygg

Hello community!

I have been thinking about the suggestion of Stevmjon to make a resolution menu
first and I have done it now.
Thank you Kevin for the hint with ogg-files. I didn't use them untill now.
Indeed I have left the pictures of the levels for further changing by anyone who wants.
In Version 2.2. I have deleted them now. As BlinkOk it doesn't matter for me, if such games
have much megbytes.
@BlinkOk: Good idea to use up-key instead of space-key. Then you have the second hand
free for a coup of coffee or a beer :)
If you like, you can download the version 2.2 now.
I think I have to implement some improvements for HappyDiver into HellEagle too.

Thanks and bye,

Sigtrygg

http://rghost.net/43263003

kevin

#23
Converting the blocks map back to pictures is pretty straight forward.  Load the blocks, load the level, make an image of the required size, draw it the level and save it..

PlayBASIC Code: [Select]
   #include "maps"
#include "savebitmap"

// Obviously this is my local path, users would need to modify this to work..
path$="E:\Downloads\HappyDiver_2.0\Media\Levels\Level_0001\"

print "Loading..."
Sync

Map=NewMap(1)
LoadMapGFx Path$+"Underwaterworld_Blocks.Bmp",Map,32,32,$00ff00ff,2
LoadLevel Path$+"Underwaterworld_Level.Map",Map,1


print "Render..."
Sync

; get the size of this level in pixels
AbsWidth =GetLevelAbsWidth(Map,1)
AbsHeight=GetLevelAbsHeight(Map,1)

; make an image this zie
img=NewImage(AbsWidth,AbsHeight,2)

; draw the map to the image
rendertoimage Img
drawmap Map,1,0,0

;
rendertoscreen

print "Saving..."
Sync

SaveBitmap "C:\PIcture.bmp",img
print "DONE"

Sync
waitkey







 Only quickly browsed the code but there's  seems to be many places where the logic can be simplified.

 A loop like this,

PlayBASIC Code: [Select]
Do
DataNumber=DataNumber+1 ;amount of data
lowerfishesData(DataNumber)=ReadData()
If lowerfishesData(DataNumber)=10000 Then Exit
Loop



 can be expressed as either an Repeat / UNtil or a conditional Do/Loop

PlayBASIC Code: [Select]
repeat
DataNumber=DataNumber+1 ;amount of data
lowerfishesData(DataNumber)=ReadData()
until lowerfishesData(DataNumber)=10000



  or

PlayBASIC Code: [Select]
do
DataNumber++
lowerfishesData(DataNumber)=ReadData()
loop lowerfishesData(DataNumber)=10000





   The pause code throws the program into a dead lock state.  Where the runtime is constantly polling the keyboard for a responce that doesn't even need to be 10 millisecond intervals let alone thousands of times per millisecond.  

 so this

PlayBASIC Code: [Select]
   If KeyState(25)=1; press "P" Key for pause and spacekey for resume

; this create a app dead lock. don't do it !
Repeat
Until SpaceKey()
EndIf




     A much more system friendly solution is to wait between iterations of the loop. So the process doesn't hog the system cpu.  

PlayBASIC Code: [Select]
   If KeyState(25)=1; press "P" Key for pause and spacekey for resume

; this create a app dead lock. don't do it !
Repeat
; suspend execution for at least 10 milliseconds. Which means the state of the space key is being checked approximately 100 times per second. The interval could really be as low as 50 milliseconds..
wait 10
Until SpaceKey()
EndIf





      Perhaps the most pressing issue is there seems to be Media leaks when changing levels..   In the load_World function for example, if we call this function twice, the previous map index will be overwritten by the next map index.    Overwriting the field doesn't delete the media, it's an integer not a reference to the map.  So the previous map is still sitting in memory.

      For example

PlayBASIC Code: [Select]
    ; create image that's 100 by 200 pixels and store it's index in the Integer variable IMAGE
Image=NewImage(100,200)

; create another image and store it's index in the Integer variable IMAGE..
; This overwrites the previous index and we've now lost that index.
Image=NewImage(256,256)

; run through the image list and see how many images exist.
For lp=1 to GetIMageQuantity()
if getimagestatus(lp)

print " IMage #"+str$(lp)
print " Width #"+Str$(GetIMageWidth(lp))
print "Height #"+Str$(GetIMageHeight(lp))
print ""
endif
next


; print the IMAGE index

print "Current Index in IMAGE ="+Str$(image)

Sync
waitkey




     
    So ideally, when changing levels it's a good idea to explicitly flush your media out of your structures.

PlayBASIC Code: [Select]
//>>>>>>>>>>>>>>>>>>>>>>>>>>> LOAD WORLD >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function load_world(level)

Path.Currentblocks=Path.blocks+"Level_"+Digits$(Level,4)+"/"+"underwaterworld_blocks.bmp"
Path.CurrentLevel=Path.Levels+"Level_"+Digits$(Level,4)+"/"+"underwaterworld_level.map"

; Like here you could check if this map already exists, then either delete it, or reuse the index.
if GetMapSTatus(gamemap(level).index)
DeleteMap gamemap(level).index
endif

gamemap(level).index=NewMap(10)

LoadMapGFX Path.Currentblocks,gamemap(level).index,32,32,RGB(255,0,255),2;$00ff00ff

gamemap(level).levelindex=GetFreeMapLevel(gamemap(level).index)

LoadLevel Path.CurrentLevel,gamemap(level).index,gamemap(level).levelindex

LevelTransparent gamemap(level).index,gamemap(level).levelindex,RGB(255,0,255)

EndFunction









Sigtrygg

Thank you very much for hints and improvements, Kevin!  :)
I try to imlement your hints for the next issue of Happy Diver.
At the moment I try to implement a harpoon shoot for stage 2
after you have managed level 5. Maybe it's a little bit more exiting
then to play the 5 levels again with the harpoon.

Until soon!

Sigtrygg

Sigtrygg

Hello community!

I have changed HappyDiver now. If you managed all five levels,
you get now into level 1, stage 2 where you get a harpoon to
shoot the fishes. But it takes some time to reload harpoon-arrow.
I played the game and everything works fine, so I hope that there
is no bug anymore.
Here you can download the game together with media and source
code.

http://rghost.net/43982110

Bye  :D

Sigtrygg


BlinkOk

that sigtrygg dude must be pretty awesome. he OWNS the high score table ;-)
i prolly get to stage 2 in about a month
nice work

micky4fun

Hi all

yep very nice Sigtrygg , when i get some spare time will give a good play
keep up the good work

mick :)

Sigtrygg

Thank you for feedback, Mick and BlinkOk!

Well, I have to admit that I have played the game more than one time  ;)
But you can delete the highscore. It will be written as new file.
Have a nice weekend!

Sigtrygg