April 29, 2024, 06:20:58 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


First attempt at EBasic 2D game/demo

Started by joeb, January 01, 2007, 11:47:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

joeb

Its rough and yeah its a breakout style game...

Clowns

First of all I have to thank whoever is the author of Smashout.eba (Paul?)
If you need to understand Lists/timing/sprites this is a great place to start.
(as you can see I BORROWED some of the list part)
Thank you Thank you Thank you

My code is ROUGH(started BASIC on VIC20). I tried to clean up a little.
Graphics are set at 1024x768 32bit and the sprites are only white now. Will update graphics later.(I can't tell you how many times I started things with the sprites and never got to programming anything so I switched.)

I have lots to do so I won't list but gravity will be my next task.

All comment welcome
Joe


Haim

Nice,
works well on my IBM T40 Laptop


Thanks for sharing.

Haim

Ionic Wind Support Team

You're welcome. Smashout! was my first attempt at a breakout style game ;)
Ionic Wind Support Team

J B Wood (Zumwalt)

You can 'fake' gravity, since it is a constant. You will have to play around with it, but simply put, its placed against the Y axis for movement.
(you probably were already aware of that)

Anyway, you start by taking into consideration an upward speed as a constant (later randomize it depending on where they hit the "paddle"), so when they impact the paddle, they are thrust upward, lets assume at a speed of 10, then you apply a -0.9875 for instance given a certain amount of time elapsed. The more thrust from the initial paddle impact, the higher they go and longer it takes for them to come back down.

There was an Atari game called circus clowns years ago that was based on this concept. Had a teeter totter type paddle, with 2 clowns, haven't looked at your example yet, but probably what you are shooting for. It had baloons to pop instead of blocks to break. The clowns had needles on there hats (although that never mattered, like the ball, the bodies of the clowns popped the balloons also)

For each balloon the clown intersected, it was given either a + or a - value to its thrust depending on "where" it hit the balloon. This value was in any of 8 directions, its an interesting project to do, more advanced than your average breakout game :)

Looking forward to when you complete it, rather my wife is, she loved that game.

barry

You may already know about this but another factor, the one that  makes Breakout games a little bit interesting, in my opinion, even though I'm not fond of them, is that the speed of the lateral movement of the paddle can also be a factor in the new vector for the ball, affecting both it's speed and direction.

By the way, you have it bouncing hitting the ground so all I had to do was sit back and watch the game play itself. :)

Nicely done.

Barry

joeb

Thanks for the response.

Jonathan (zumwalt) Wood:
It will be an updated version of Clowns I played on VIC20/C64. Thanks for the info on gravity, I had an idea of it but you have cleared it up considerably.

barry:
I plan to make the speed relative to gravity and how close it hits to the teeter center(more force if the clown hits farther from it) The idea is to make it travel in arcs.
I don't advocate killing clowns. ;D (its another thing I have to add to make it more into a game)

Joe

J B Wood (Zumwalt)

LOL just loaded it, its the best remake I have seen in years!
Going to give this version to my daughter, she'll never loose! :)
awesome, just down right awesome

Bruce Peaslee

A little rough, yes, but it made me smile.  :D
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

joeb

January 04, 2007, 12:30:22 AM #8 Last Edit: January 05, 2007, 12:29:22 AM by joeb
Update:
Now has gravity and arc paths and new set of balloons when you clear(Thanks again to Paul and Smashout)
I still have to add lives but for now lets just say he has rubber shoes or floor like that Bud Lite commercial ;D

The gravity variable is .9875 is divided by 2 a few times but since I didn't add a real timer to the game it is easier to to slow it up this way. Next project I'll have to include a timer, learn from past mistakes. This will also help with screen sync, animation, fades etc.

Anyway it plays much better and added 1.2 to gravity each time the balloons clear.

Til next update

Joe


****UPDATE FINAL *****
Now is a complete game. You need 3 .wav files; all from XP Media folder.(if you don't have them just REM out)
The game speeds up for every level. Not to bad for a weeks work.

Now on to other things....maybe and RPG(like Final Fantasy) or RTS(like Age of Empires 2) something involving maps. May take some time though; too bad I have to work.

CONST srezx=1024
CONST srezy=768

IF CREATESCREEN( srezx, srezy, 32) < 0
    MESSAGEBOX 0,"Error creating screen","error"
    END
ENDIF
dim score,teeterX,updn,teeterframe,click,mousebutton,clownx,clowny,clownframe,speedX,count,collision,blcollision as int
dim random,level,level_end,lives as int
dim key$ as string
dim gravity,speedY as float
TYPE brick
int x,y /* upper left corner of brick */
int visible /*whether brick exists */
int blframe
ENDTYPE
restart:
gravity=0.12
level=1
lives=3
num_lines=3
bricks_per_line=10
clown = LOADSPRITE(GETSTARTPATH + "clown.bmp", 0, 0, 2)
balloon = LOADSPRITE(GETSTARTPATH + "balloon.bmp", 0, 0, 4)
teeterL = LOADSPRITE(GETSTARTPATH + "teeterL.bmp", 0, 0, 2)
teeterR = LOADSPRITE(GETSTARTPATH + "teeterR.bmp", 0, 0, 2)
clownx=srezx/2
clowny=srezy-384
clownframe=0
speedX=3
speedY=0
count=0
updn=0
brickList = ListCreate
gosub InitializeBricks()
'flip
'goto exit
SETCURSOR FrontBuffer,@CSCUSTOM,0
SPRITEMASKCOLOR clown,rgb(255,0,255)
SPRITEMASKCOLOR balloon,rgb(255,0,255)
SPRITEMASKCOLOR teeterL,rgb(255,0,255)
SPRITEMASKCOLOR teeterR,rgb(255,0,255)
SPRITEDRAWMODE clown,@TRANS
SPRITEDRAWMODE balloon,@TRANS
SPRITEDRAWMODE teeterL,@TRANS
SPRITEDRAWMODE teeterR,@TRANS

DO
    FILLSCREEN RGB(127,127,127)
    WRITETEXT 0, 0, "Score:"+str$(score)+"          Level:"+str$(level)+"          Lives:"+str$(lives)

count=count+1
IF count>19 then count=0
teeterX=MOUSEX()

IF teeterX>srezx-128 then
teeterX=srezx-128
ENDIF
speedY=speedY+gravity
IF collision and speedY>0 then
PLAYWAVE "C:\WINDOWS\Media\chimes.wav", @SNDASYNC
clownx=teeterX+(teeterframe*64)
clowny=srezy-132
updn = NOT(updn)
teeterframe=abs(updn)
SPRITEFRAME teeterL, teeterframe
SPRITEFRAME teeterR, teeterframe
speedY=-speedY
collision=0
GOTO jmp1
ENDIF
mousebutton=MOUSEDOWN(1)

IF mousebutton and click=0 then
updn = NOT(updn)
teeterframe=abs(updn)
click=1
SPRITEFRAME teeterL, teeterframe
SPRITEFRAME teeterR, teeterframe
ENDIF
IF click=1 and mousebutton=0 then
click=0
ENDIF
jmp1:
IF count=0 or count= 9 then clownframe=not(clownframe)
if clownx>srezx-63 or clownx<0 then speedX=-speedX
if clowny>srezy-63 then
speedY=0
FRONTPEN FRONTBUFFER, RGB(0,0,0)
    WRITETEXT clownx+10, clowny-30, "OUCH!",FRONTBUFFER

PLAYWAVE "C:\WINDOWS\Media\Windows XP Critical Stop.wav", @SNDSYNC
clowny=srezy-384
clownx=srezx/2
lives-=1

endif
if clowny<0 then speedY=1
clownx=clownx+speedX
clowny=clowny+int(speedY)

SPRITEFRAME clown, clownframe

DRAWSPRITEXY clown,clownx,clowny
DRAWSPRITEXY teeterL,teeterX,srezy-68
DRAWSPRITEXY teeterR,teeterX+64,srezy-68

IF updn=0 THEN collision=SpriteCollidedEx( clown, clownx, clowny, clownframe, teeterR, teeterX+64, srezy-68, teeterframe)

IF updn=-1 THEN collision=SpriteCollidedEx( clown, clownx, clowny, clownframe, teeterL, teeterX, srezy-68, teeterframe)

gosub DrawBricks()
    FLIP
gosub CheckBalloons
if lives=0 then goto gameover
UNTIL GETKEY <> ""
gameover:
    WRITETEXT 0, 0, "Score:"+str$(score)+"          Level:"+str$(level)+"          Lives:"+str$(lives)
    WRITETEXT srezx/2-50, srezy/2, "G A M E   O V E R"
    WRITETEXT srezx/2-130, srezy/2+20, "Press 'R' to restart, Any other key to exit."

flip
do
key$=getkey
UNTIL key$ <> ""

exit:
ListRemoveAll(brickList,TRUE)
FREESPRITE clown
FREESPRITE balloon
FREESPRITE teeterL
FREESPRITE teeterR
if key$="r" or key$="R" then goto restart
CLOSESCREEN
END

SUB InitializeBricks()
FOR y=1 to num_lines
FOR x=1 to  bricks_per_line
pBrick = ListAdd(brickList,NEW(brick,1))
#<brick>pBrick.x =(x-1)*(srezx/bricks_per_line)
#<brick>pBrick.y =(y-1)*80+20
#<brick>pBrick.visible = TRUE
#<brick>pBrick.blframe=0

NEXT x
NEXT y
RETURN
ENDSUB
SUB DrawBricks()
FOR pBrick = EACH brickList AS brick
IF #pBrick.visible
spriteframe balloon,#pBrick.blframe
drawspritexy balloon,#pBrick.x,#pBrick.y
if #pBrick.blframe=2 then

#pBrick.visible=FALSE
else
#pBrick.blframe=-clownframe
endif

ENDIF
blcollision=False
if #pBrick.y=20 then #pBrick.x+=2
if #pBrick.y=100 then #pBrick.x-=2
if #pBrick.y=180 then #pBrick.x+=2
if #pBrick.x<0 then #pBrick.x=srezx
if #pbrick.x>srezx then #pBrick.x=0
blcollision=SpriteCollided( clown, balloon, TRUE)
if blcollision and #pBrick.blframe<2 then
score+=100
speedY=0
if speedX<0 then
speedX=3+rnd(4)
else
speedX=-(3+rnd(4))
endif
blcollision=0
#pBrick.blframe=2
PLAYWAVE "C:\WINDOWS\Media\Windows XP Balloon.wav", @SNDASYNC
endif
skip:
NEXT
RETURN
ENDSUB
SUB CheckBalloons
level_end = TRUE
FOR pBrick = EACH brickList as brick
if #pBrick.visible THEN level_end = FALSE
NEXT
IF level_end
level++
ListRemoveAll(brickList,TRUE)
clownx=srezx/2
clowny=srezy-384
clownframe=0
speedX=3
speedY=0
count=0
gravity+=.12
brickList = ListCreate
gosub InitializeBricks()
ENDIF
return
endsub