File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get ground postion

 
sudde gameeef
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to get ground postion, no matter where your player is standing.

2d array: (0=sky, 1=ground, 2=player)



so to get ground position i do this.



problem with above code is that it will only get me the last row postion and thats the ground postion. it wont take in count the ground above it.

so i did this in a loop. i am not sure what to do in if statment so it will give me ground postion, no matter where is player is standing.

 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would search for the player first. Once you find her, you might just have to subtract 1 from her height. Of course, that assumes that she's a well-grounded player.

I don't really understand either of your code snippets. "a" represents the array I guess. What's tile_size?
 
sudde gameeef
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




i just change some of the stuff.

tile_size = 32;

this code justt making a rectange where there is ground and storeing in arraylist


getter



this code loop though arraylist and see is player is touching the rectanges in arraylist.



this code will find the ground no matter where is the player. bc i getting player y postion.

but the problem is that 1st player will be touch the ground(1) so it will get player y postion + height and thats the ground postion. if he moves right than there is another ground block on top. so he touchs that and moves the ground up. and so on...

now notic if player moves left than he is no ground under him and he is not touching any ground blocks. so he should fall down untill he touch another block. but this doesnt happed. he just stays there and no ground block under him.

i tried this but didnt worked i dont know why.

 
Campbell Ritchie
Sheriff
Pie
Posts: 47261
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudde gameeef wrote: . . .

2d array: . . .
No, it isn’t. There is no such thing as a 2D array in Java. What you have is an array of arrays.

I have had to go back and correct some of the formatting errors in your post, because you have lines too long. I didn’t correct the inconsistent indentation, nor the use of tabs and spaces together, nor the identifier names which do not follow the conventions for this language.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic