Main Menu

BallDown=)

Started by ATLUS, October 31, 2008, 03:22:53 PM

Previous topic - Next topic

ATLUS

when that beside saw such play on telephones. Has Thought to do her(it) on PlayBasic. ;D And here is that was got for 2 work hourses.
Can be Kevin will add her(its) afterwards in list example :)
Manual:
Sense:
it is necessary using platforms to hold ball on medium of the screen that he not go upwards or bottom of the screen
control:
left arrow left turn
right arrow right turn
down turn jump down
secrets=):
If you score > 1000 and < 1200 prize time and on screen to appear piece of the ball which add 2 lifes

PlayBASIC Code: [Select]
; PROJECT : DBS
; AUTHOR : ATLUS
; CREATED : 31.10.2008


; EDITED : 31.10.2008
; ---------------------------------------------------------------------

setfps 60
//////backdrop screen
Steps=36
Dim Palette(Steps)
Dim Palette2(Steps)

For lp=0 to steps
Palette(lp)=rndrgb()
next
//*************************************
;//////render to images///////////////////////////////
createimage 1,220,5
rendertoimage 1
ShadeBox 0,0,220,5,RndRGB(),RndRGB(),RndRGB(),RndRGB()
rendertoscreen

createimage 2,30,30
rendertoimage 2
circleC 15,15,15,1,rndRGB()
rendertoscreen
///*******************////////////////////////////////
//////////////////////////////////////creating sprites
;player
createsprite 14
spriteimage 14,2
centerspritehandle 14
//prize
CreateImage 3,45,45
RenderPhongImage 3,xl,yl,RGB(250, 5, 67),200,7.0
createsprite 45
spriteimage 45,3
SpriteCollision 45,On
spriteCollisionClass 45,%0010
SpriteCollisionMode 45,1
//platforms
for Sprites=1 to 5
CreateSprite Sprites
SpriteImage Sprites,1
CenterSpriteHandle Sprites
x=Rnd(GetScreenWidth()-32)
y=Rnd(GetScreenHeight()-32)
PositionSprite sprites,x,y
SpriteCollision Sprites,On
SpriteCollisionClass Sprites,%0010
SpriteCollisionMode Sprites,1
next
/////////////////////////////////


/////////////////////////////////exist dynamic
x1=rndrange(20,780)
x2=rndrange(20,780)
x3=rndrange(20,780)
x4=rndrange(20,780)
x5=rndrange(20,780)
y1=rndrange(10,590)
y2=rndrange(10,590)
y3=rndrange(10,590)
y4=rndrange(10,590)
y5=rndrange(10,590)

xp=400
yp=15
//////////////////////////life parametres and score
lv=3
score=0
speed#=2
xprize=rndrange(20,780)
yprize=700


do
cls rgb(0,0,0)

PositionSprite 14,xp#,yp;position player
////////////control NPC
if leftkey()=true then xp#=xp#-(6+speed#)
if xp#<0 then xp#=0
if rightkey()=true then xp#=xp#+(6+speed#)
if xp#>800 then xp#=800
if downkey()=true
yp=yp+33
flushkeys
endif
/////////////////////////////////
//*****creating platforms
positionsprite 1,x1,y1
positionsprite 2,x2,y2
positionsprite 3,x3,y3
positionsprite 4,x4,y4
positionsprite 5,x5,y5
//////move platforms
y1=y1-speed#
y2=y2-speed#
y3=y3-speed#
y4=y4-speed#
y5=y5-speed#
//////
if y1<0 then y1=600:x1=rndrange(20,780)
if y2<0 then y2=600:x2=rndrange(20,780)
if y3<0 then y3=600:x3=rndrange(280,520)
if y4<0 then y4=600:x4=rndrange(20,280)
if y5<0 then y5=600:x5=rndrange(520,780)

yp=yp+5;gravitation player
/////colision contact
ThisSprite=SpriteHit(14,GetFirstSprite(),%0010)
if ThisSprite>0 then yp=yp-10:score=score+1:speed#=speed#+0.0001
///pizeup
prizeup=SpriteHit(14,45,%0010)
if prizeup>0 then lv=lv+2:yprize=700

////minus lifes
if yp>610 then lv=lv-1:yp=10:xp#=rndrange(20,780)
if yp<-5 then lv=lv-1:xp#=rndrange(20,780):yp=10



DrawBackDrop(780,40,600,Steps,Palette())

/////display play statistick
print "Life:"+Str$(lv)
print "score:"+str$(score)
//position prize
///prize time up
if score>1000 and score<1200 then yprize=yprize-3
if yprize<-5 then yprize=600:xprize=rndrange(20,780)

positionsprite 45,xprize,yprize

drawallsprites
sync
loop
////backdrop function Thanks Kevin!!!
Function DrawBackDrop(Xpos#,Ypos#,Radius#,Steps,Colours())
Static BaseAngle#=Wrapangle(Baseangle#,1.0)

segmentsize#=360.0/Steps
c1=Colours(0)
c2=Colours(1)

Login required to view complete source code

kevin

#1
  Neat little game,  Here's a slightly cleaned up version.  This version uses an array to store the walls in, so it can easily expanded to use more or less walls.


PlayBASIC Code: [Select]
   setfps 60
//////backdrop screen
Steps=36
Dim Palette(Steps)
For lp=0 to steps
Palette(lp)=rndrgb()
next

//*************************************
;//////render to images///////////////////////////////
createimage 1,220,5
rendertoimage 1
ShadeBox 0,0,220,5,RndRGB(),RndRGB(),RndRGB(),RndRGB()
rendertoscreen

createimage 2,30,30
rendertoimage 2
circleC 15,15,15,1,rndRGB()
rendertoscreen
///*******************////////////////////////////////
//////////////////////////////////////creating sprites
;player
createsprite 14
spriteimage 14,2
centerspritehandle 14
//prize
CreateImage 3,45,45
RenderPhongImage 3,xl,yl,RGB(250, 5, 67),200,7.0
createsprite 45
spriteimage 45,3
SpriteCollision 45,On
spriteCollisionClass 45,%0010
SpriteCollisionMode 45,1




Type TWalls
Spr
Endtype

Dim wall(5) as twalls


//create platforms
for Wall=1 to 5
Xpos=rndrange(20,780)
ypos=rndrange(10,590)
Spr=newSprite(xpos,ypos,1)
Wall(wall).Spr=spr
CenterSpriteHandle Spr
SpriteCollision Spr,On
SpriteCollisionClass Spr,%0010
SpriteCollisionMode Spr,1
next
/////////////////////////////////



// Playerss Stuff
xp=400
yp=15
//////////////////////////life parametres and score
lv=3
score=0
speed#=2
xprize=rndrange(20,780)
yprize=700


do
cls rgb(0,0,0)

////////////control NPC
PositionSprite 14,xp#,yp;position player
if leftkey()=true then xp#=xp#-(6+speed#)
if rightkey()=true then xp#=xp#+(6+speed#)
Xp#=ClipRange(xp#,0,800)

if downkey()=true
yp=yp+33
flushkeys
endif


/////////////////////////////////
//////move platforms
For lp=1 to 5
if Wall(lp)
Spr=Wall(lp).Spr
MoveSprite Spr,0,-Speed#
if GetSpriteY(Spr)<0
PositionSprite Spr,rndrange(20,780),600
endif
endif
next


/////colision contact
ThisSprite=SpriteHit(14,GetFirstSprite(),%0010)
if ThisSprite>0
Ypos=GetSpriteY(ThisSprite)
Yp=Ypos-15
score=score+1
// Bump Speed
speed#=speed#+0.0001
else
yp=yp+5;gravitation player
endif



prizeup=SpritesOverlap(14,45)
if prizeup>0 then lv=lv+2:yprize=700

////minus lifes
if yp>610 then lv=lv-1:yp=10:xp#=rndrange(20,780)
if yp<-5 then lv=lv-1:xp#=rndrange(20,780):yp=10

DrawBackDrop(780,40,600,Steps,Palette())

/////display play statistick
print "Life:"+Str$(lv)
print "score:"+str$(score)
//position prize
///prize time up

if score>1000 and score<1200 then yprize=yprize-3
if yprize<-5 then yprize=600:xprize=rndrange(20,780)

positionsprite 45,xprize,yprize

drawallsprites
sync
loop




////backdrop function Thanks Kevin!!!
Function DrawBackDrop(Xpos#,Ypos#,Radius#,Steps,Colours())
Static BaseAngle#=Wrapangle(Baseangle#,1.0)

segmentsize#=360.0/Steps
c1=Colours(0)
c2=Colours(1)

firstc2=c2

Login required to view complete source code



ATLUS

 :o Thanks for arrays idea!! I much thought as easier do move walls now has seen

kevin

#3
    Learning to use arrays is an important step towards making better and easier to maintain programs.   While confusing at first,  mastering them will open up a world of possibilities.   My advice, hit the help files and tutorials board.  

ATLUS

Thanks!!! I lear this!!!