Author Topic: Hit detection with xlib  (Read 4783 times)

0 Members and 1 Guest are viewing this topic.

SuperSmashcz

  • Guest
Hit detection with xlib
« on: December 19, 2006, 09:04:00 am »
Ok, im very very VERY new at xlib, and ive done all the tutorials, and i understnad how they work, ect..
But now id like to know how to do a hit detection with xlib  :)smile.gif
anyone point me in the right direction?

Also, ive been re reading the tutorial, and it saids we can only use 8X8 sprites? What? So i cant use a 16X16? :(sad.gif


P.S. Don't double post unless it is to bump or for other sensible reasons

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
Hit detection with xlib
« Reply #1 on: December 19, 2006, 09:40:00 am »
Use edit button rather then double post.  Wait a little and someone who uses xlib will answer.

Floodkiller

  • Guest
Hit detection with xlib
« Reply #2 on: December 19, 2006, 11:06:00 am »
1) Hit detection is what you make it.  If you know how to do matrix hit detection, you know how to do a basic hit detection in xlib.  Anything more complicated I haven't figured out yet, since my games haven't gotten to the point where I need a complicated hit detection.

2) You can use 16x16, just read the txt file with the xlib download in order to find out how to use each in your real( commands.

SuperSmashcz

  • Guest
Hit detection with xlib
« Reply #3 on: December 19, 2006, 12:06:00 pm »
The problem is idk how to do a matrix hit detection..:(sad.gif All i want is a basic wall hit detection..

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
Hit detection with xlib
« Reply #4 on: December 19, 2006, 12:07:00 pm »
i belive the manual says the sprites must have width of multiples of 8, so 16 is definitely fine, you only have to write 2 for sprite width instead of 1 (along with 16 in height not 8)

SuperSmashcz

  • Guest
Hit detection with xlib
« Reply #5 on: December 19, 2006, 12:08:00 pm »
Oh ok, *hits self* didnt think of that one :Dbiggrin.gif

Offline Speler

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 857
  • Rating: +6/-2
    • View Profile
Hit detection with xlib
« Reply #6 on: December 19, 2006, 03:19:00 pm »
*Super Speler

Offline necro

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1295
  • Rating: +17/-2
  • +3 vaporal mustache
    • View Profile
Hit detection with xlib
« Reply #7 on: December 19, 2006, 06:37:00 pm »
@SuperSmashcz: please try to put a bit more content into each post...like when you said you got it, explain the method you now "get" in case it might help any other member in the future

@super speler:why not just merge the posts like I did?

Matrices can be used for a lot of complex tricks and as you can store several digits in a matrix in decimal (which xlib will ignore) you can store wether something is for instance a floor, wall, teleport, etc.  You could then retrive this data through a series of rounding methods...but this can get slow.  

And out of couriosity, is this forum actualy for xlib related coding advice/help?
I'm like a woot burger with awesome fries


VB.Net, C#, C++, Java, Game Maker

SuperSmashcz

  • Guest
Hit detection with xlib
« Reply #8 on: December 21, 2006, 12:45:00 pm »
Ok, apperently i didnt "got it"
  ive got all the map data in a matrix,im using xlib, if that helps, but ive got 0 as wall, and 2 as a walkable tile, im using 16X16 sprites, basicaly giant squares, the method for detection is using
If[A](A+X+1,B+X+1) =2 : then
does movement code

i cant understand whats wrong, the problem is on the left and bottem sides of the screen, the sprite can go into the wall sprite "half way", where on the left and top, it stops just before hitting the sprite. realy confusing, let me kno if u need more code.

Floodkiller

  • Guest
Hit detection with xlib
« Reply #9 on: December 22, 2006, 03:51:00 am »
Well, if it hits it halfway, then either something is wrong with your displaying techniques, collision checks, or scrolling.  In my game, it was the scrolling, because the formula wasn't put together correctly and pushed the character 1 square ahead of the matrix's hit detection.  It was a simple fix (add one to the subtracted variable), but back to your problem. I would need more code from you, or I can't tell specifically what it is.

Offline dinhotheone

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 410
  • Rating: +2/-1
    • View Profile
Hit detection with xlib
« Reply #10 on: December 22, 2006, 01:42:00 pm »
going halfway in is odd... the most plausible thing would be some mixup between bit numbers, like your scrolling an 8*8 char using a 16x16 tile map  or something. code would defenitely be useful though

Edit: just thought of some stuff... one thing that may be wrong is the fact that x and y on the matrix corrospond to the top left spot on the screen. so when you are calculating what spot you are on you have to subtract one from x and y when you add screen location coordinates with regular position coordinates. another thing that might be a problem is that if you are using smooth movent instead of jump movement (moving a pixel at a time instead a tile at a time) you have to check for hit detection on every corner of the sprite.

Shazane Koronova

  • Guest
Hit detection with xlib
« Reply #11 on: January 15, 2007, 08:37:00 am »
I too have a problem with collision detection.

this is my code, X and Y are the coordinates of the sprite and are always multiples of 8:

c1-->
CODE
ec1
If [A](X/8,Y/8)=0
c2
ec2

in most places I get an invalid dimension error, and where I don't get that it just doesn't detect the collision and overwrites the tile.

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
Hit detection with xlib
« Reply #12 on: January 15, 2007, 08:45:00 am »
http://tifreakware.net/tutorials/83p/b/tifw/les8.htm

That tutorial explains hit detection using matrices, lists and strings. Not the greatest in the world, but it should help you out with learning how to create a good, simple hit detection routine...  
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Offline necro

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1295
  • Rating: +17/-2
  • +3 vaporal mustache
    • View Profile
Hit detection with xlib
« Reply #13 on: January 15, 2007, 08:49:00 am »
yeah, would need to show more more code like how the player's drawing code works to be sure, but I think you need to swich the x and y in your case.
I'm like a woot burger with awesome fries


VB.Net, C#, C++, Java, Game Maker

Shazane Koronova

  • Guest
Hit detection with xlib
« Reply #14 on: January 15, 2007, 09:06:00 am »
QUOTE