|
|
Discussion Forum
"Snake" Ggame on LPC1768
Next Thread | Thread List | Previous Thread
Start a Thread | Settings
| Details |
Message |
|
Read-Only
Author Damian doles
Posted 9-May-2012 00:14 GMT
Toolset ARM
|
 "Snake" Ggame on LPC1768
Damian doles
Hi everyone :) I'm writing project for my studies and my idea is
write a game something like Snake. I have big problem with checking
pixels, OK I'll explain it. I draw a line on LCD, draw and draw but
as you see on movie if the "snake" enters on himself there should to
end game and show "GAME OVER", but I don't know how can I check it. I
have some idea for it. I declarated a table which has two dimensions
- height and width LCD. When "snake" go anywhere, for example if he
goes up, he safe "1" to the table on current coordinates x and y. One
word - it safe last position. And there I check if new position will
be "1" program stop. At the beginnig all table has "0". Every draw
pixel put "1" to the table. I think you understand my idea. But...It
doesn't work. I don't know why. When I flash processor everything
stop and I can see only white display...No reaction. It works when I
give small table...not as a LCD size, for example 50x50 ([50][50])
and draw snake on small place on the LCD. How can I do it...? I hope
that you help me with it. And the movie... sorry for quality.
http://www.youtube.com/watch?v=3cSJ6_oOo1M&feature=youtu.be
and code...I must safe it to txt file because my thread is too
long (when I have written it, there was error about to much words on
text)
https://www.dropbox.com/s/t2l0ujs3twyqt5z/main.c
I think that it looks like good for analyze and watch ;)
|
|
|
Read-Only
Author Damian doles
Posted 9-May-2012 00:18 GMT
Toolset ARM
|
 RE: "Snake" Ggame on LPC1768
Damian doles
oops I forgot to write that each "1" put was in draw function on
each ifs. It looked like lcd_tab[x][y] = 1;
|
|
|
Read-Only
Author Trevor Page
Posted 9-May-2012 01:35 GMT
Toolset ARM
|
 RE: "Snake" Ggame on LPC1768
Trevor Page
Generally, I think your idea is the way you would have to do it.
That is, maintain a two-dimensional 'collision map' using the array
as you have suggested. However, memory is obviously a limitation.
Therefore I would suggest that you consider drawing in blocks of
pixels as the snake advances, effectively reducing your resolution
and hence reducing the size of your collision array. For example,
each advance of the snake might be a 10 x 10 block of pixels.
Therefore assuming a 1/4 VGA LCD, you would have 32 x 24 discrete
blocks to record rather than 320 * 240.
Another way would be to actually read back the state of individual
pixels from the LCD controller's frame buffer memory. Without looking
at datasheets, I don't know whether or not you can do this with your
particular LCD / controller.
If you can't get your collision array to actually work for you
then you'll need to post up some example code. Format it using the
instructions seen above the textbox when you're posting.
|
|
|
Read-Only
Author Per Westermark
Posted 9-May-2012 07:57 GMT
Toolset ARM
|
 RE: "Snake" Ggame on LPC1768
Per Westermark
Note that you want your collision map to only use one bit for each
collision.
A char array of 50*50 is 2500 bytes. So it quickly gets large.
Having one bit/pixel would instead make it 7*50 = 350 bytes.
With a 320x240 display, a full map would be 40*240 = 9600 bytes
which is small enough to work with even if you have a full 1:1 map
between LCD pixels and collision map. Going 2 pixels on LCD for one
pixel of collision map, it would quickly have shrunk to 2400 bytes -
same as your original 50x50 if used with full bytes.
|
|
|
Read-Only
Author paul george
Posted 14-May-2012 06:01 GMT
Toolset ARM
|
 RE: "Snake" Ggame on LPC1768
paul george
Hi,
Here is a link which can help you.
http://www.simonhuggins.com/courses/cbasics/course_notes/snake.htm
|
|
|
Read-Only
Author Damian doles
Posted 14-May-2012 09:28 GMT
Toolset ARM
|
 RE: "Snake" Ggame on LPC1768
Damian doles
Thanks for every answers, I've almost finished my game. I must to
make only DAC and play some melody when I'll lose the game or go to
the next level.
|
|
Next Thread | Thread List | Previous Thread
Start a Thread | Settings
|
|
|