News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

For Foxes Sake WIP

Started by micky4fun, August 19, 2012, 03:54:41 AM

Previous topic - Next topic

Sigtrygg

Hello Micky!

Game looks great!
I am looking forward for more!  :)
Sky moving looks very fine!

Greetings

Sigtrygg

kevin

#31
  Looks really good, but it's impossible to play here, way too fast..


  We can't assume a any system has Vsync enabled (or is even supported for that matter), as it's frequently disabled in video card drivers.   Therefore, it shouldn't be used a frame rate limiter.    To detect if a video card diver is actually waiting from the top of each frame during a sync (flipping the screen buffers),  we can time the lenght of each frame.    Systems that are waiting, will give us steady delta of 16/17 ticks (or more) per frame assuming a 60 frames per second video refresh at resolution.   Systems that don't wait will end up with an average delta inside a millisecond or so.   Allowing our program to detect the environment upon which it's running.     

PlayBASIC Code: [Select]
   // request vsync
ScreenVsync true

// array to hold the clock ticks at the start of each new frame
Dim SyncTicks(30)

// flip the buffer 30 times to collect from information
// about the the users system
For lp =0 to 30
Cls 0
Sync
SyncTicks(lp)=timer()
next

// Calc the average delta time per frame
TotalTicks=0
For lp =1 to 30
TotalTicks+= SyncTicks(lp)-SyncTicks(lp-1)
next
SyncAverageDelta#=TotalTicks/30.0

// If the delta is bellow say 5 ticks per frame, then it's highly unlikely this
// system has vsync enabled or supported
if SyncAverageDelta#<5
print "Doesn't Support Vsync"
else
print "Has Vsync"
endif


Sync
waitkey





BlinkOk

#32
nice work mick. it's lookin great.
if you're interested i could make up some tiles for you. (actually i already have)
but it's up to you as always. no biggie if you wanna do them yourself

micky4fun

#33
Hi All

sorry yep i will put the option to disable screenvsync and set fps in game ,
though i could use code snippet to do it automatically ,
btw the new way code snippets are done does look good , but when i copy it , ie highlight it and copy it and then paste it into PB , it needs a bit of editing around to get it  working
the old code snippet worked straight away , but i think i read that you are going to do a copy button !

yeh BlinkOk any tiles that you can supply would be great ,
thanks ATLUS its coming along
sigtrygg , yeh the tileimage makes this quite simple as long as the image begining and end line up , its called something but i cant remember what , think Kevin or BlinkOk will know

thanks
mick :)

kevin

#34
Quotebtw the new way code snippets are done does look good , but when i copy it , ie highlight it and copy it and then paste it into PB , it needs a bit of editing around to get it  working
the old code snippet worked straight away , but i think i read that you are going to do a copy button !

your using IE ?   (LInk)


BlinkOk

#35
ok no worries mick. the only thing about these tiles is you need to be able to overlay tiles one on top of the other some times and some are animated.
(you might need me to merge the bridge edge tile and the start of the bridge. just let me know how you wanna deal with that)

ANIMATED VERSION
note: i just bunged all the images in the .rar file. some may not be tiles


ps: forgot the dark tiles
pps: background image in rar is wrong
ppps: let me know if you need any other animations or tiles
pppps: can you make the water transparent using a blend (normal blend)? is that gonna work?
ppppps: just had a thought; if you make the bg2 image 1000px wide rather than 1200px it will add more variation to the background in combination with bg1
pppppps: added stuff for the paint brush

BlinkOk

ppppppps: jump animations

micky4fun

Hi All

Quoteyour using IE
yes version 9 , though i have tried it since and it seems fine now ,

Thanks BlinkOk for tiles and gfx's , all fantastic , fox nice n sharp now , will have a muck around weekend and see how i can imply them ,
see what i come up with ,
not tried any tile animations yet , will look on how to load animations gfx's into a map block cell
Quotepppps: can you make the water transparent using a blend (normal blend)? is that gonna work?
dont know if i can do this , dont know if there is a way to make a tile semi transparent , of if there is another way to do water effect
but will look into this

mick :)

micky4fun

#38
Hi all

well ive started to do some animations blocks a little stumbling though , in the example i have copied from the example folder , cut down version , i include below ,

"" i can animate a block , starting from image position 0 to 10 , so 10 frames , but say i want to start from position 20 of the image and goto position 30 , in the forward motion , how do i do that so it loops nicely ?""

haha i have sussed this out now , so no worries on that , just the Constant z thing please



also what is Constant z=$80000000 needed for what does that do i know it dont animate without it ? , can i change value , or is this the value required , is there a decimal value
PlayBASIC Code: [Select]
Setfps 75
LoadImage "212.bmp",2
width=32
height=32
ThisMap=GetFreeMap()
CreateMap ThisMap,2
MakeMapGFX ThisMap,2,width,height,34,$ff0000
MapAnimQuantity ThisMap,10

For lp=0 To GetMapAnims(ThisMap)
ThisAnim=GetFreeMapAnim(thismap)
CreateMapAnim ThisMap,ThisAnim,10

For lp2= 0 To 10
PokeMapAnim ThisMap,ThisAnim,lp2,10+lp2
Next
ResizeMapAnim ThisMap,ThisAnim,10

MapAnimFrameRate ThisMap,ThisAnim,15

MapAnimType ThisMap,ThisAnim,1

Next

MapAnimQuantity ThisMap,678

CreateLevel ThisMap,1,10,10

Constant z=$80000000

For lp=0 To 10
PokeLevelTile 1,1,2,1,z
PokeLevelTile 1,1,2,2,3
Next

LevelTransparent 1,1,1
LevelAnimated 1,1

Repeat
Cls 0

DrawMap 1,1,x#,y#

UpdateMapAnims ThisMap

Sync
Until EnterKey()

DeleteMap 1
WaitKey

END



any help on this would be great and save me lots of time

thanks guys
mick :)

kevin

#39
Quotelso what is Constant z=$80000000 needed for what does that do i know it dont animate without it ? , can i change value , or is this the value required , is there a decimal value

 it's the sign bit in a 32bit integer.. These days we use the PBMapAnim_Mask constant when tagging a tile as being an animation index, rather than a block index in the map.

 
Quote
   The PokelevelTile() function will store either Tiles Index or Animation Index directly into a level array.


     Animation Note: When play basic draws a level, it distinguishes between normal block and animation indexes tiles by performing a Bit TEST on value. Normal block indexes should be stored as positives values (from 0 to the number of blocks this map has). To store an Animation index, the index needs to be OR'd with the PBMapAnim_Mask constant. This will appropriately tag this value as animation index, rather than a block index.



I.e. Poking an animation index into a level.
 
 PokeLevelTile MyMap,MyLevel,TileXpos,TileYpos, MyAnimationIndex Or PBMapAnim_Mask
 


  as for what integer it is, it's this

PlayBASIC Code: [Select]
   print $80000000
print PBMapAnim_Mask
sync
waitkey







made a quick mock up,




ATLUS

BlinkOk, again very good style!

BlinkOk

thanks atlus. looks like kevin has the transparency working too. nice work

micky4fun

#42
Hi all

ok thanks Kevin , see you have a nice mock up running looks very nice you would have a complete game within a few hours , haha , any chance of the code so i can see how the transparency works within the tiles ,

blinkOk will get to work today starting a larger level off ,  take it that the water part of the level will only be here and there within the level



thanks mick :)

ps

just tried a few different animations for water and coins , so i set the animation mask to $80000000 for first animation seqence that i have set up then $80000001 fro the next and so on, thats works ok here
but still need help with transparent blocks or water effect please

thanks
mick :)

kevin


   As you can see, there's nothing to it,  although you'll have to convert the png's to ARGB format.  Just load and re-save them in Paint.net or anything that defaults ARGB  format pngs. 


PlayBASIC Code: [Select]
    #include "framesheetanims"

Type tFrameSheets
Coin
FoxWalking
Water
EndType

Type tGameImages
BackDrop(2)
Clouds(2)
Dirt(10)
Trees(10)
EndType

Dim FrameSheet as tFrameSheets
Dim GameImage as tGameImages

Path$=currentdir$()+"Media\"

; Tell it load AFX formatted frames

FrameSheetCreationType(2)
FrameSheet.Water =LoadSequentialFrameSheet(Path$+"water####.png",1,9,0)
FrameSheetCreationType(8)

FrameSheet.Coin =LoadSequentialFrameSheet(Path$+"coin####.png",1,9,-1)
FrameSheet.FoxWalking =LoadSequentialFrameSheet(Path$+"walk####.png",1,9,-1)


GameImage.Backdrop(0) =LoadNewFXImage(Path$+"Bg2.bmp")
GameImage.Backdrop(1) =LoadNewFXImage(Path$+"Bg1.png")

GameImage.Clouds(0) =LoadNewaFXImage(Path$+"cloud1.png")
GameImage.Clouds(1) =LoadNewaFXImage(Path$+"cloud2.png")

GameImage.Dirt(1) =LoadNewImage(Path$+"dirt tile left.png",8)
GameImage.Dirt(2) =LoadNewImage(Path$+"dirt tile.png",2)
GameImage.Dirt(3) =LoadNewImage(Path$+"dirt tile right.png",8)
GameImage.Dirt(4) =LoadNewImage(Path$+"dirt dark.png",2)


GameImage.trees(0) =LoadNewImage(Path$+"tree1.png",8)
GameImage.trees(1) =LoadNewImage(Path$+"tree2.png",8)
GameImage.trees(2) =LoadNewImage(Path$+"tree3.png",8)




Screen=NewImage(800,600,2)

Spin =NewAnim(FrameSheet.Coin,2)
Water =NewAnim(FrameSheet.Water,2)
FoxWalking =NewAnim(FrameSheet.FoxWalking,2)

;Setfps 50

Do

RenderToImage Screen

PlayerX#+=1

ScreenX#=Mod(PlayerX#*0.10,800)
Xpos=-ScreenX#
DrawImage GameImage.Backdrop(0),Xpos,0,false
DrawImage GameImage.Backdrop(0),Xpos+800,0,false

img=GameImage.Backdrop(1)
ScreenX#=Mod(PlayerX#*0.25,800)
Xpos=-ScreenX#
DrawImage img,Xpos,GetSurfaceHeight()-GetImageHeight(img),true
DrawImage img,Xpos+800,GetSurfaceHeight()-GetImageHeight(img),true

ScreenX#=-Mod(PlayerX#*1.5,800)

DrawImage GameImage.Clouds(1),Screenx#+0100,150,true
DrawImage GameImage.Clouds(1),Screenx#+0100+800,150,true
DrawImage GameImage.Clouds(0),Screenx#+0500,60,true
DrawImage GameImage.Clouds(0),Screenx#+500+800,60,true

BlockHeight =64
Xpos =0
Ypos =GetSurfaceHeight()-BlockHeight
DrawDirtString("012444423000000",xpos,ypos)

DrawTree(0,XPos,Ypos)

Ypos-=BlockHeight
DrawDirtString("00122222230000",xpos,ypos)

DrawTree(1,XPos+128,Ypos)

Ypos-=BlockHeight
DrawDirtString("0000012430000",xpos,ypos)

DrawTree(2,XPos+256,Ypos)


Ypos-=BlockHeight
DrawDirtString("000000123000",xpos,ypos)


DrawAnim FoxWalking,400,300,true
DrawAnim FoxWalking,500,350,true

ThisFrame =StepAnim(Spin)

GridImage ThisFrame,400,ypos,3,1, true


ThisFrame=StepAnim(Water)
Width =GetImageWidth(ThisFrame)
Ypos =GetSurfaceHeight()-GetIMageHeight(ThisFrame)
For lp=0 to 800 step width
DrawAlphaImage ThisFrame,lp,Ypos,0.5,true
next


rendertoscreen
DrawImage Screen,0,0,false
setcursor 0,0


Sync
loop



psub DrawTree(index,XPos,Ypos)
ThisIMage=GameImage.Trees(Index)
drawimage ThisImage,Xpos+32,Ypos-GetImageHeight(ThisImage),true
EndPsub



Psub DrawDirtString(s$,xpos,ypos)
For lp =1 to Len(s$)
Index=mid(s$,lp)-asc("0")
ThisIMage =GameImage.Dirt(index)
if ThisImage
drawimage ThisImage,xpos,Ypos,true
endif
Xpos+=64
next
EndPsub




 
    I wouldn't actually do it like that, but hey it's mock up.     


Quote
   80000000 for first animation seqence that i have set up then $80000001 fro the next and so on, thats works ok here

    Just  or the animation index with the PBMapAnim_Mask constant. 
   
    AnimatedTileValue =  MyAnimIndex or PBMapAnim_Mask

    PokeLevelTile  Map,Level, Xpos,Ypos,   AnimatedTileValue


Quote
but still need help with transparent blocks or water effect please

  crack open the help, scroll down to images and you'll find   DrawAlphaImage








BlinkOk

#44
i have no idea what an ARGB format .png is. can you post an image so i can look at it?

is it a 32bit .png rather than an 8 bit .png?