Collision detection in Jack?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Collision detection in Jack?

A_Random_Person
Is there a efficient way to implement collision detection in Jack? I am making a Pac-Man game, and I need a fast (and simple) way to detect wall collision. How can I do this?
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

ivant
Pacman is a relatively simple game, but even it will require some sort of model of the game world. That is, you need to know where there are walls, dots, large dots that turn pacman into the hunter, cherries, ghosts, pacman itself. I'm sure I missed something. You'll need to know where each of those objects is at any given time, so you better make a model for them.

In the game loop you will just have to update the model depending on what happens, like key presses, and ghosts moving and turning, and you need to update the screen as well. The collision detection in the game model can be much simpler than general purpose one. Hint: even though the object appear to have different forms, you can treat them as squares.

Except the walls, of course. But they are quite static anyway, so you'd want to represent them differently.
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

A_Random_Person
I am currently representing the walls as a simple 2D array. When Pac-Man moves forward, before it is rendered onto the screen, it will check the 2D array to check if there is a wall.
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

A_Random_Person
The only problem is that constructing a 2D list in Jack is very tedious. my Pac-Man maze will require 32×28=896 cells. Is there a fast way to construct lists (like in most languages, constructing a list will only require <Whatever> = {<Whatever[0]>, <Whatever[1]>, <Whatever[2]>, ... <Whatever[n]>})
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

ivant
Can you think of a way to easily map 2d grid to a 1d array? (Hint: look at the video memory mapping)
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

A_Random_Person
I cannot find any videos with their name containing "memory mapping" in week 3. Can you please be a little more precise?
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

ivant
I haven't watched the videos at all. But the video memory is continuous, you can think of it as a 1 dimensional array, and yet it is displayed as a 2D screen. How is that accomplished?

For example, if you want to toggle a pixel with coordinates row 10, column 20, how can you find the right address where where this pixel is controlled?
Reply | Threaded
Open this post in threaded view
|

Re: Collision detection in Jack?

Lozminda
In reply to this post by A_Random_Person
Hi
I might be jumping in here and not knowing what i'm talking about, so there's my caveat.

1) There is somewhere on this forum a list of various programs written in jack which are definitely worth a look for some excellent solutions to problems.

2)Complicated maths, decimal maths, 3d graphics have been got around by creating basically predefined tables which are poked into memory on game initialisation, ie the work has been done outside of jack, then ported in, by the programmer tediously (i'd guess, but maybe there’s a way around that too) inputting the relevant data into the program, which it then uses later..

I'm sure you're already thinking about this..but there's more than one person reading your posts !

Good luck !