News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question on how to make this code loop??

Started by OceanJeff32, September 24, 2005, 03:21:26 AM

Previous topic - Next topic

OceanJeff32

Take a look at this code I've got, I have been trying for about 1 hour + to get it to loop properly, but can't get it to work.  I simply want the next iterations to access the array information in blocks array.

The mystery is this:  when I add the 16 to the pointer to the array manually it works fine!!  The blocks both draw perfectly, and the ball bounces off of both blocks, and even in between them beautifully...why can't I add to the index displacement with a variable and produce the same result...the program crashes and wants to talk to microsoft...

How humiliating,

Let me know if you can help,

Jeff c
:eek


[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

AeroASM

Which part of the code is the problem in? (it is very long!)

The code as you posted it worked fine; was this the buggy or non-nuggy version?

OceanJeff32

The code blocks that draw the blocks on the screen, I would like to shorten to one block that loops through an array of blocks (eventually the screen will have hundreds of blocks...).  I can't get the arrays to behave when I use a variable displacement in the [base + displacement] reference.

It works fine the way I have it, but it is cumbersome to write out the code for each block separately.  I am studying code now that uses arrays, but can't get it for some reason...

Also, would like to draw and move and detect collisions for multiple balls, but without arrays like I would use for the blocks, this is almost an impossibility.

I'm working on it, but may not get there until next month...

hope someone can help,

jeff c
:boohoo:
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

OceanJeff32

GOT IT!!! Congratulations are definitely in order!

Now I can complete this demo...

Notice that though I'm using GDI, the only GDI call I'm making is SetDIBitsToDevice(), that's it!  I'm drawing all the pixels myself, well the Pentium is anyways.

Maybe it had to take a hurricane making landfall (I hope there aren't any humans around for the storm...) for me to get this right.

The code is attached, and it's easy now to put the blocks on the screen by adjusting the blocks array, and don't forget the blocktotal variable has to be one more than the number of blocks!

:U :dance: :clap: :cheekygreen:

Later, and yes, there's more to come on this.

jeff c
:eek

[attachment deleted by admin]
Any good programmer knows, every large and/or small job, is equally large, to the programmer!