• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

get ground postion

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic