game grid images and setup

Problems with Canvas, OpenGL, etc...

game grid images and setup

Postby acriib » Tue Oct 12, 2010 4:09 pm

I'm in the beginning process of creating my first 2d game and it's a
puzzle game (sort of like bejeweled) where I would have 7 different images randomly spread
out across in a 7x7 grid totaling 49 images total.
Basically there would be a way to match pieces and make them
disappear, then the pieces above would fill the new empty spaces, and then new random pieces would
appear to fill the gaps left at the top of the screen.

I have been struggling with this I know how to load images etc. but I
cant seem to wrap my head around getting the basic getting this basic structure set up
where it's actually usable. I cannot find any tutorials etc that cover this sort of thing. If
someone could give me any pointers, or point me in a direction that my fill in the gaps for
what I am looking for that would be greatly appreciated.

Thanks,
Al
acriib
Freshman
Freshman
 
Posts: 7
Joined: Sun Oct 03, 2010 7:05 pm

Top

Re: game grid images and setup

Postby Tage Nielsen » Wed Oct 13, 2010 9:02 pm

I would organize my 7x7 grid using collections such as:

ArrayList<Bitmap> firstColumn = new ArrayList<Bitmap>();

where you can use .remove(int index) to delete "disappear" pieces. Then you can use .add(Bitmap name) to add the new image to the end of the list. Using 7 ArrayLists allows you to keep separate accounting for each column in your grid.
Tage Nielsen
Junior Developer
Junior Developer
 
Posts: 17
Joined: Wed Oct 13, 2010 8:02 pm

Re: game grid images and setup

Postby acriib » Thu Oct 14, 2010 4:49 am

Tage thanks for giving me an avenue to explore, i'll look this up and play with it a bit to see if I can get it to my liking.. much appreciated.
acriib
Freshman
Freshman
 
Posts: 7
Joined: Sun Oct 03, 2010 7:05 pm

Re: game grid images and setup

Postby acriib » Mon Oct 25, 2010 6:14 pm

That works perfectly! Thanks again

What I am struggling with now is removing an item from the arraylist that i "touch".
For example I have a 7 by 7 grid separated into 7 vertical arraylists with 7 random images populating the whole grid,
how do it up so when I touch the screen on a particular image, that image will disappear.

I have my touch event setup to get the coordinates and I can remove an item by specifying the index number in .remove. however I am having trouble translating where I touch, to the the arraylist item(s)

Pardon my inexperience here but I have been banging my head against the wall with no resolve.

Thanks
acriib
Freshman
Freshman
 
Posts: 7
Joined: Sun Oct 03, 2010 7:05 pm

Re: game grid images and setup

Postby MrSykkoh » Mon Oct 25, 2010 9:04 pm

acriib wrote:That works perfectly! Thanks again

What I am struggling with now is removing an item from the arraylist that i "touch".
For example I have a 7 by 7 grid separated into 7 vertical arraylists with 7 random images populating the whole grid,
how do it up so when I touch the screen on a particular image, that image will disappear.

I have my touch event setup to get the coordinates and I can remove an item by specifying the index number in .remove. however I am having trouble translating where I touch, to the the arraylist item(s)

Pardon my inexperience here but I have been banging my head against the wall with no resolve.

Thanks


Hey

Im not the biggest expert on this subject, but i have some basic knowledge.
I guess you have to make a "virtual" grid too...
like defining 7x7 blocks but each block have to contain the image height and width and then divide your "cursor" result with 7..

Hope you understand, my first post here soo hehe =)
MrSykkoh
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Oct 25, 2010 9:00 pm

Re: game grid images and setup

Postby jonbonazza » Wed Oct 27, 2010 9:01 pm

The best way to do this is to create a subclass of Bitmap that contains the position as a data member(s). Then, you use the onTouchEvent() method coupled with the KEY_DOWN field to gather the touches, once a touch is received, you need to use the location of the touch and the positions of the various Bitmap subclasses to determine which "tile" was touched. Another options is to make the grid from buttons and set the background of each button to a square image. This will allow you to automatically inherit the onClick() method of the button.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest