News:

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

Main Menu

WIP - Bike Jump

Started by Laskiapina, September 03, 2011, 08:16:52 AM

Previous topic - Next topic

Laskiapina

So I made something this morning. Nothing too special.


Controls and instructions:

First press: Arrow up - accelerate
Then hold: Arrow down - get ready for the jump
Release arrow down and the guy jumps!
Use arrows to the left and right to balance the bike.

Other player uses WASD the same way.
Number keys from 1 to 4 change the window size.


The little flag on the top left tells the wind direction. Avoid the spikes of course.
You get points when you jump far and make volts (go around, not sure of the word).

Download: http://dl.dropbox.com/u/7879998/BikeJump.zip



Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

micky4fun

hi all

good start to a nice game, are you going to make it a scrolling course so you do muti jumps , so after course say 10 jumps the highest score wins

keep up the good work  ;)

mick :)

kevin

#2
  looks good, but rather than rotate such a small sprite with just a linear scale, you should look at enabling filtering.


PlayBASIC Code: [Select]
   file$="BikeJump\GFX\p1.png"

i=loadnewfximage(file$)

rendertoimage i
w=getimagewidth(i)
h=getimageheight(i)
for ylp=0 to h-1
for xlp=0 to w-1
ThisPixel=point(xlp,ylp) and $00ffffff
if ThisPixel <>0
dotc xlp,ylp,(ThisPixel and $00ffffff) | $ff000000
endif
next
next

rendertoscreen
PrepareAFXimage i

s=newsprite(200,200,i)
spritedrawmode s,2
spritefilter s,on
scalesprite s,2.25

Do
Cls 255
turnsprite s,0.25
drawallsprites
sync
loop





   

Laskiapina

Micky: If you mean like the two bikers would first jump once and then again and again and then their points would be added together and then show you who won, then yes, I've been thinking about that. Sort of like tournament. We'll see how long I'll be making this. I'm sick this month after surgery, so I have to have something to do though ;)

Kevin: There's some new stuff for me in there.
1. What does it mean when you use POINT and add ") and [color]" to the end?
2. What does the symbol | do?
3. And then.. what does that "POINT... DOTC" do that isn't done with just turning SPRITEFILTER on?
Finished projects so far: Kumiankka, Meals of the Dragon, Fisut, Draw Old, Reikäkopio, Blindage, Escape from Millmier

Homepage: Not yet named project

kevin

#4
Quote1. What does it mean when you use POINT and add ") and [color]" to the end?

  It's using the AND rule to remove alpha channel bits (if any, there shouldn't be) from the colour.    Colours are 4 bytes (8bit) packed together into a 32bit integer (ARGB format),  so there's an ALPHA level, RED level, GREEN & BLUE Level.  

 You could do the same thing like this

  ThisColour=Point(X,y)

  R=RgbR(ThisCOlour)
  G=RgbG(ThisCOlour)
  B=RgbB(ThisCOlour)
 
  ThisColour=ARGB(0,R,G,B)

  So what it's doing is removing the alpha channel and preserving the R,G,B colour data.  


Quote2. What does the symbol | do?

  |  = OR   It merges the bits of the two values together.     Since the Alpha channel is the top 8 bits in the integer, so if we OR the value $ff000000 with our clean colour value, it's the same as setting the Alpha Channel value to 255.

  ThisColour=Point(X,y)

  R=RgbR(ThisCOlour)
  G=RgbG(ThisCOlour)
  B=RgbB(ThisCOlour)
 
  ThisColour=ARGB(255,R,G,B)

 
 
PlayBASIC Code: [Select]
   ; binary
print %11111111000000000000000000000000

; Hex
print $ff000000

; argb
print argb(255,0,0,0)

sync
waitkey




 
Quote3. And then.. what does that "POINT... DOTC" do that isn't done with just turning SPRITEFILTER on?

  The whole routine is filling in the  alpha channel representation of the image.   So we load the image as a FX format, run though it and slap an alpha channel in, then tell PB to convert this FX image into an AFX image (and FX image with alpha channel).      So the sprite is no longer using MASK COLOUR for transparency beyond that, it's rendering the pixels based on the brightness of the Alpha channel value at each point.  



micky4fun

hi all

QuoteMicky: If you mean like the two bikers would first jump once and then again and again and then their points would be added together and then show you who won,
yep thats what i mean , a nice little 2 player tournament would be good

mick :)

kevin

#6
  Knocked a up mock of this with a super sample styled post process. So the screen is drawn twice the size and blurs and scaled down.    

PlayBASIC Code: [Select]
   path$="BikeJump\gfx\"

openscreen 320,240,32,1

img_ground=loadnewfximage(path$+"m3.png")

img_bike=loadnewfximage(path$+"p1.png")

drawimage img_ground,0,0,true


Screen=NewFxImage(640,480)

rendertoimage screen
Cam1=NewCamera()
cameracls cam1,off
cameraviewport cam1,0,0,640,240

Cam2=NewCamera()
cameraviewport cam2,0,240,640,480
cameracls cam2,off


spr_player1=newsprite(000,120,img_bike)
spritedrawmode spr_player1,2
centerspritehandle spr_player1
scalesprite spr_player1,2

spr_player2=newsprite(000,120,img_bike)
spritedrawmode spr_player2,2
centerspritehandle spr_player2
scalesprite spr_player2,2



blurlevel#=9.4

rendertoscreen
do

clsscene
capturetoscene
capturedepth 100
drawimage img_ground,0,-250,false

turnsprite spr_player1,0.5
turnsprite spr_player2,2

positionspritex spr_player1, GetcameraX(Cam1)+300
positionspritex spr_player2, GetcameraX(Cam2)+300

drawallsprites


drawcamera Cam1
drawcamera Cam2

movecamera Cam1,1.25,0
movecamera Cam2,2.50,0

x=GetCamerax(cam1)
w=GetIMageWidth(img_ground)
if X>W then positioncamerax cam1,x-w

x=GetCameraX(cam2)
if X>W then positioncamerax cam2,x-w


if spacekey()
blurlevel#=rndrange#(4,12)

endif

; blur it some we're smudge the pixels into a soap
blurimage screen,blurlevel#

; draw it scaled down 50% with bilinear filter applied
drawrotatedimage screen,0,0,0,0.50,0.50,0,0,false+8

Sync
loop






BlinkOk

very nice work Laskiapina. got to wait for my kid to finish school to try it out.

QuoteKnocked a up mock of this with a super sample styled post process. So the screen is drawn twice the size and blurs and scaled down.
i prefer Laskiapina's crisp render. that one is way too blurry