News:

Function Finder  Find all the functions within source code files

Main Menu

Shapesteroids W.I.P

Started by medwayman, March 25, 2006, 02:41:46 PM

Previous topic - Next topic

medwayman

Hi all  

Well I lost the will to code for a while, but here I am again. Actually a mate of mine asked about my game so I showed him and he really liked it. Anyway, after seeing the game again I thought I've got to finish this damn thing.

Ok this is not the latest version, that's broke. I was working on saucer timing and selection when I stopped work, and I have no idea what's going on with that. To be honest there wont be much difference anyway, although I know I fixed some bugs that you may come across, so there's no need to report anything untoward at the moment.  


Some points about the game as it stands:

>The one player game starts at a higher level for instant mass asteroid action! Two player starts on level 1

>You will get a random saucer every 10 seconds. The small one may be too accurate. What do you think?

>The ship doesn't check for asteroids before re-spawning.  

>The options work but the key selection is broke.

>There is no sound but I will be using the original beeps.

>I need to play with ship acceleration and max asteroid speeds

keys:
left/right arrows to rotate.
Up arrow to thrust.
Ctrl to fire.
Space to hyperspace (no hyperspace in the game but you will need it to enter your name) 1 or 2 to start game.


I'm sure you know what Asteroids looks like but here are some screenshots anyway

www.wobglass.pwp.blueyonder.co.uk/images/shape01.png
www.wobglass.pwp.blueyonder.co.uk/images/shape02.png

www.wobglass.pwp.blueyonder.co.uk/downloads/Shapesteroidsnew.zip
EDIT: dead links removed July,2013


Kevin, will you have a problem with this being a copy? If you like when I release the final version I could do another with changed graphics and sound.

:)

kevin

Why would i have a problem with it ?

It's looking pretty shape !

medwayman

I know you wanted to avoid copyrighted material for the comp, (or maybe that was because you were giving out prizes.) and seeing as Atari are still selling asteroids (well I think they are anyway) they may have a problem with it.
Ultimately I want to help promote PlayBasic whenever I can, so I wanted to make sure you could use the game. If you want to that is.


:)

kevin

For the compo, My main concern was people ripping truck loads of somebody else's media and using it their game.   But the irony is that their remakes anyway.  So the potential does exist to get a slap on the wrist from the original owners..  But i'm not too worried..

  Anyway, I think you should probably keep it traditional.   So I'm wondering how your drawing the shape edges actually.  Curious.. :)

Big C.

#4
I want to make a remake of Asteroid myself for Learning-purposes with Play Basic... i began to start programming, but if i see the demo... too late... medwayman has make a great job... so i can hope, that medwayman will published his Sourcecode (if he want) very late, so i have a chance to finishing my Work...  ;)

With asteroid I set off into the world of the video games, then still as Arcade machines version... it is long, long here...


QuoteSo I'm wondering how your drawing the shape edges actually.

Is this what you mean Kevin?

PlayBASIC Code: [Select]
; PROJECT : Asteroid Shapes
; AUTHOR : Big C.
; CREATED : 26.03.2006
; ---------------------------------------------------------------------

Dim StoneBig(3)
Dim StoneMedium(3)
Dim StoneSmall(3)

; Schiff als Vektor-Grafik erstellen
Ship = GetFreeShape()

CreateShape Ship,4,4

SetShapeVertex Ship,0,0,24
SetShapeVertex Ship,1,10,0
SetShapeVertex Ship,2,20,24
SetShapeVertex Ship,3,10,16

SetShapeEdge Ship,0,0,1
SetShapeEdge Ship,1,1,2
SetShapeEdge Ship,2,2,3
SetShapeEdge Ship,3,3,0

; Den Null-Punkt des Vektors von der
; linken, oberen Ecke verschieben
ShiftShape Ship,-10,-12

; Bullet als Vektor-Grafik erstellen
Bullet = GetFreeShape()

CreateShape Bullet,4,4

SetShapeVertex Bullet,0,0,0
SetShapeVertex Bullet,1,1,0
SetShapeVertex Bullet,2,1,1
SetShapeVertex Bullet,3,0,1

SetShapeEdge Bullet,0,0,1
SetShapeEdge Bullet,1,1,2
SetShapeEdge Bullet,2,2,3
SetShapeEdge Bullet,3,3,0

; Stone #1 als Vektor-Grafik erstellen
StoneTmp = GetFreeShape()

CreateShape StoneTmp,11,11

SetShapeVertex StoneTmp,0,0,20
SetShapeVertex StoneTmp,1,10,15
SetShapeVertex StoneTmp,2,15,0
SetShapeVertex StoneTmp,3,30,0
SetShapeVertex StoneTmp,4,35,10
SetShapeVertex StoneTmp,5,50,15
SetShapeVertex StoneTmp,6,50,35
SetShapeVertex StoneTmp,7,45,45
SetShapeVertex StoneTmp,8,35,50
SetShapeVertex StoneTmp,9,15,50
SetShapeVertex StoneTmp,10,0,35

SetShapeEdge StoneTmp,0,0,1
SetShapeEdge StoneTmp,1,1,2
SetShapeEdge StoneTmp,2,2,3
SetShapeEdge StoneTmp,3,3,4
SetShapeEdge StoneTmp,4,4,5
SetShapeEdge StoneTmp,5,5,6
SetShapeEdge StoneTmp,6,6,7
SetShapeEdge StoneTmp,7,7,8
SetShapeEdge StoneTmp,8,8,9
SetShapeEdge StoneTmp,9,9,10
SetShapeEdge StoneTmp,10,10,0

ShiftShape StoneTmp,-25,-25

StoneBig(1) = StoneTmp

StoneTmp = GetFreeShape()
CopyShape StoneBig(1), StoneTmp
ScaleShape StoneTmp,0.50

StoneMedium(1) = StoneTmp

StoneTmp = GetFreeShape()
CopyShape StoneMedium(1), StoneTmp
ScaleShape StoneTmp,0.50

StoneSmall(1) = StoneTmp


; Stone #2 als Vektor-Grafik erstellen
StoneTmp = GetFreeShape()

CreateShape StoneTmp,12,12

SetShapeVertex StoneTmp,0,0,15
SetShapeVertex StoneTmp,1,15,10
SetShapeVertex StoneTmp,2,20,0
SetShapeVertex StoneTmp,3,40,0
SetShapeVertex StoneTmp,4,35,15
SetShapeVertex StoneTmp,5,50,15
SetShapeVertex StoneTmp,6,50,35
SetShapeVertex StoneTmp,7,35,40
SetShapeVertex StoneTmp,8,35,50
SetShapeVertex StoneTmp,9,15,50
SetShapeVertex StoneTmp,10,10,40
SetShapeVertex StoneTmp,11,0,35

SetShapeEdge StoneTmp,0,0,1
SetShapeEdge StoneTmp,1,1,2
SetShapeEdge StoneTmp,2,2,3
SetShapeEdge StoneTmp,3,3,4
SetShapeEdge StoneTmp,4,4,5
SetShapeEdge StoneTmp,5,5,6
SetShapeEdge StoneTmp,6,6,7
SetShapeEdge StoneTmp,7,7,8
SetShapeEdge StoneTmp,8,8,9
SetShapeEdge StoneTmp,9,9,10
SetShapeEdge StoneTmp,10,10,11
SetShapeEdge StoneTmp,11,11,0

ShiftShape StoneTmp,-25,-25

StoneBig(2) = StoneTmp

StoneTmp = GetFreeShape()
CopyShape StoneBig(2), StoneTmp
ScaleShape StoneTmp,0.50

StoneMedium(2) = StoneTmp

StoneTmp = GetFreeShape()
CopyShape StoneMedium(2), StoneTmp
ScaleShape StoneTmp,0.50

StoneSmall(2) = StoneTmp


; Stone #3 als Vektor-Grafik erstellen
StoneTmp = GetFreeShape()

CreateShape StoneTmp,13,13

SetShapeVertex StoneTmp,0,0,20
SetShapeVertex StoneTmp,1,15,15
SetShapeVertex StoneTmp,2,5,10
SetShapeVertex StoneTmp,3,15,0
SetShapeVertex StoneTmp,4,40,10
SetShapeVertex StoneTmp,5,40,15
SetShapeVertex StoneTmp,6,25,20
Login required to view complete source code


Big C.

kevin

#5
Big C,

  Nah, I was just wondering what mode he's using to draw them.  


   Also, don't forget to Lock and UNLock the buffer when draw a number of shapes.  

PlayBASIC Code: [Select]
Do
Cls 0
lockbuffer ; lock surface
DrawShape Ship, 400, 300, 1
DrawShape Bullet, 400, 250, 1


For i = 1 to 3
DrawShape StoneBig(i), 200*i, 100, 1
DrawShape StoneMedium(i), 200*i, 150, 1
DrawShape StoneSmall(i), 200*i, 200, 1
Next i
; when you finnished drawing shapes unlock it again
Unlockbuffer ; unlock surface

Sync
Loop




medwayman

#6
QuoteAnyway, I think you should probably keep it traditional.
I was always going to release it as a clone, but would have done another version if required. :)



QuoteSo I'm wondering how your drawing the shape edges actually. Curious..
Each shape is drawn at rgb(180,180,180) in edge mode and then redrawn at rgb(255,255,255) in vertex mode. The saucer and ship shots are drawn with the dot command. I was going to make the letters and numbers from shapes when I started out but opted for images in the end.



QuoteAlso, don't forget to Lock and UNLock the buffer when draw a number of shapes
I didn't think of that. I'll have to give it a go.



Quotemedwayman has make a great job
Thanks glad you like it. :)  



Quoteso i can hope, that medwayman will published his Sourcecode (if he want) very late, so i have a chance to finishing my Work...
I'm afraid my code for this game is a real mess. There are no comments, and I'm sure if I went through it with a fine-toothed comb id find redundant code and variables. The only thing you would learn from this is how not to program, and will probably give yourself a headache in the process!

A better option would be to help as you go. I can show you sections of the code if you want to know how I did something or explain my methods, and there are others on the boards who, I'm sure, would be keen to help you solve any problems. :)


I'm going to restart work on this game next weekend and will stick with it until the end. For the moment I'm starting a new project – some nice easy coding to get me back in the mood. :D

kevin

QuoteI was always going to release it as a clone, but would have done another version if required.

Got for both then and give Tommy some competition :)


QuoteEach shape is drawn at rgb(180,180,180) in edge mode and then redrawn at rgb(255,255,255) in vertex mode. The saucer and ship shots are drawn with the dot command. I was going to make the letters and numbers from shapes when I started out but opted for images in the end.

When I saw the white vertexes I was thinking you'd use alpha 50/50 mode or something.  

Prolly a wise choice about the font.  Painful to set up, but it would have been fun to scale and rotate the text .. hmm :)


QuoteI didn't think of that. I'll have to give it a go.

 Assuming your not using a camera ?.  it's probably an easy way to get some extra free speed.  As every time a line/dot is drawn the video buffer has to be locked.  Which can be very time consuming. So by locking it manually than drawing batches of shapes/dots. This will minimize the impact the locking.

medwayman

QuoteWhen I saw the white vertexes I was thinking you'd use alpha 50/50 mode or something.
I didn't know you could apply FX to shapes I'll have to look at that



QuoteProlly a wise choice about the font. Painful to set up, but it would have been fun to scale and rotate the text .. hmm
I fancy doing another vector game at some point, and with my shape editor (if I can make it that is) I'll be able to do that no prob. I've got loads of ideas, but we'll have to see what happens. No clones this time though.



QuoteAssuming your not using a camera ?. it's probably an easy way to get some extra free speed. As every time a line/dot is drawn the video buffer has to be locked. Which can be very time consuming. So by locking it manually than drawing batches of shapes/dots. This will minimize the impact the locking.
Wow! Was getting around 170fps but with buffer lock it's up to 280-300+ and that's with max stuff happening! (XP2400 - 2000mhz, radeon 9250)  I'm not using a camera

Big C.

medwayman

QuoteEach shape is drawn at rgb(180,180,180) in edge mode and then redrawn at rgb(255,255,255) in vertex mode.
can you post an example? I have played around with the Ink-Command and the DrawShape-Mode 0 and 1 but this don't have the described effect to me...

I assume your Shapes being transparent or?

medwayman

#10
All you do is draw the shape in edge mode (1) Change the colour and redraw the same shape over the top but in vertex mode (0)

This is the loop for the example you posted. Run this in your programme and you should see the effect. :)  


PlayBASIC Code: [Select]
Do
Cls 0
Ink RGB(180,180,180)
DrawShape Ship, 400, 300, 1
Ink RGB(255,255,255)
DrawShape Ship, 400, 300, 0

DrawShape Bullet, 400, 250, 1

For i = 1 To 3
Rem set the desired colour and draw the shapes in edge mode
Ink RGB(180,180,180)
DrawShape StoneBig(i), 200*i, 100, 1
DrawShape StoneMedium(i), 200*i, 150, 1
DrawShape StoneSmall(i), 200*i, 200, 1
Rem change the colour and redraw the shapes in vertex mode
Ink RGB(255,255,255)
DrawShape StoneBig(i), 200*i, 100, 0
DrawShape StoneMedium(i), 200*i, 150, 0
DrawShape StoneSmall(i), 200*i, 200, 0
Next i
Sync
Loop




medwayman

I've shifted development to my laptop and found that this game is totally unplayable on it's LCD screen. Is this a problem with all LCD's or just older ones?

This poses two problems for me...

First, what do I do about the game? I guess I could offer an option to play with antialised images as well as with shapes, although it would be nice to stick with just shapes. What do you think any other options?  

The second dilemma is my shape editor. I'd planned to have option to draw shapes freehand for use in vector games like Shapesteroids but is there any point? With more and more people using LCD's all the time (I just assume that to be the case?) no one is going to play them. May as well just use images in the first place.

kevin

While laptops can have rather awful refresh rate.  But then again, so do most older desk tops.    Speed wise, it plays a bit slow on my computer also.  Having seen a previous version, I suspect that's a combination of my newer video card (well replacement) having a slower refresh generally and the level of recursion generated from the inter object collisions.

   Inter objects collisions can produce a lot of recursion. Ie. 10 objects produce 10*10=100 collision checks, 20objects produce 400 checks.  So the more objects the worse it gets!

   One way to reduce the collision overhead is by  partitioning the screen.    In this case, you could sector the display into vertical areas.  from 2 to 10 would certainly do.  Before updating you tag what sectors each object falls into.  Then do that again as you move them..   When checking for collision, you run through your object list,  and only check the objects they share a region with.  It's a little extra work to set up, but reduces most of the recursion dramas.   Generally partition is a slower for a few objects, but much quicker for lots.  

  Moreover, you (we all should)  should look into implementing some type of delta time solution.

medwayman

#13
I'm not having a speed problem. The shapes shift in and out of view as they move, and the lines are very thin when you can see them. I don't know much about LCD's but I know they refresh in a different way to CRT's so I thought maybe that had something to do with it. But to be honest I'm not really sure.

I've changed the prog so you can press left alt to switch fps between 0 and 60 (you have to press twice as the game will freeze the first time). I'm also using manual buffer lock now. If you select max fps your ship is invincible. All collision still takes place and the rocks will explode on the ships hull. Download in first post is updated.

Does it play fast enough now? (The player ship's response is slower than it will be in the finale atm.) Also, what fps do you get at max fps?

QuoteOne way to reduce the collision overhead is by partitioning the screen. In this case, you could sector the display into vertical areas. from 2 to 10 would certainly do. Before updating you tag what sectors each object falls into. Then do that again as you move them.. When checking for collision, you run through your object list, and only check the objects they share a region with. It's a little extra work to set up, but reduces most of the recursion dramas. Generally partition is a slower for a few objects, but much quicker for lots.
That's a good idea, something to consider for future projects.



QuoteMoreover, you (we all should) should look into implementing some type of delta time solution.

I not sure about delta timing At low fps objects can leap large distances and miss collision checks, and things start to looks messy. I think id rather the player didn't play if their system couldn't handle it.  


Btw my laptop is a Compaq Evo N610c

Edit: D/L should work now.

kevin

Older,  LCD generally has a much slower refresh rate. As such their apparently not the display of choice for gaming in general.  As pixels refresh rate is much slower than a crt.   Leading to 'dragging/ghosting' effects with moving images.    

 While I don't have one, that was definitely problem on my sisters older laptop, but the newer one (18months or so) doesn't seem as noticeable.

 Another issue while i think of it,  is full screen exclusive modes.   Since LCD's have a physical resolution,  one can only wonder how full screen exclusive modes are viewed on them.  As if the screen mode was different to the monitor res, the image has to be Either bordered or stretched...

QuoteI not sure about delta timing At low fps objects can leap large distances and miss collision checks, and things start to looks messy. I think id rather the player didn't play if their system couldn't handle it.

Well that only occurs if your game moves objects by the game clock. Since collision is regional,  I'm not a big fan of that method.

Given logic and redraw run with a single thread.  I much prefer to execute the game logic at a fixed rate, and interleave redraws.    So as the refresh get slower on some box, the game still behaves the same.  However as you suggest there's a point where it's just not worth it.  

 I'm slapping together a partition example ATM.