iterate images

BlitzPlus Forums/BlitzPlus Beginners Area/iterate images

Kirkkaf(Posted 2011) [#1]
I'm not sure if iterate is the correct word please let me know otherwise (i'm new to all this).

I want to create a simple game similar to this: http://www.helicoptergame.net/

If you have played the game I would like to change certain things like blocks not getting in the way and allowing the helicopter (ball in my case) to follow the mouse.

For the walls I would like to draw 25 rects top and bottom at different random heights. So you would have to navigate your ball over/under the tall walls.

I would ideally like to use only blitz graphics not drawn sprites but I can't think how I would go about drawing 20 rects top and bottom then "iterate" (search) through the rects to check for collision.

I don't want anyone to write the code for me as I learn best doing it myself, just need some ideas on how to do this. Maybe some pseudocode will help. Hope thats the right term.

I'd appreciate any help.

Last edited 2011

Last edited 2011

Last edited 2011


Kirkkaf(Posted 2011) [#2]
With a little more thinking I was able to come up with this:
Graphics (500, 300)

SetBuffer (BackBuffer ())

iRectX = -20
iRectX2 = -20

For i = 1 To 25
    iRectX = iRectX + 20
    Rect (iRectX, 0, 20 Rnd (10, 130))
Next

For i = 1 To 25
    iRectX2 = iRectX2 + 20
    Rect (iRectX2, Rnd (170, 290), 20, 130)
Next

Flip ()

WaitKey()

End()


If you run this code this is what I want my walls of the game to look like. I have not yet thought of a way to iterate through the rects to check for collision and to check wether x< 0 then delete rect.

How can I go about doing this?

Thanks.


Kirkkaf(Posted 2011) [#3]
How can I create an array for all 25 top wall rects with all there values stored?

EDITED: Please read my other posts for this to make any sense.

Last edited 2011


Andy_A(Posted 2011) [#4]
Yo K,

You're all over the place with the questions, and that's not a bad thing, but the reason why is that you haven't planned enough.

Here's what I would suggest, create an outline of what you're trying to accomplish. No need to go overboard with creating a 'design' document, just keep it simple.

Here's an example:

1) Set up screen
2) Initialize variables and arrays
3) Create graphics (storing coords in array while they're being created)
4) Repeat 'Game loop'
....Cls
....Update player position
....Update obstacle positions
....Check for collisions (see 'ImagesCollide' function in help file)
....Update Score
....Until player hits [Escape] key
5) Release resources ('FreeImage')
6) End

Treat each of the outline steps as a one task that needs to be completed (functions). When you're done with all tasks game is finished.


Kirkkaf(Posted 2011) [#5]
Hey "A" :)

That's really helped alot actually amazing how simple it can seem when the pieaces are laid out from you. I will definatly try this when it comes to my next project.

I also tend to ask a question that maybe I should have a go at working out myself, I have just figured out how 2 dimensional arrays work, something I have always struggled with.

Things are looking up :)

Thanks.

Last edited 2011


Andy_A(Posted 2011) [#6]
WolRon has a page with helpful tutorials for new B+ programmers

arrays:
http://home.cmit.net/rwolbeck/programmingtutorial/

more code examples:
http://www.blitzbasement.net/tutorials/tutorialindex.html


Kirkkaf(Posted 2011) [#7]
Thanks for the links some of this information will come in handy.