Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Game is coming along, need help with proper keypress detection functions

Author
Message
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 30th Dec 2005 22:54 Edited at: 30th Dec 2005 22:59
Here's my code, posted 2 versions. first is my full original code with 8 functions to detect keypresses; one for each of the 8 home row keys. second version is my attempt to make one function that could detect for all 8 keys. Both versions work, my problem is that neither will detect past the first (bottommost) entry in the array, regardless of what happens to that cell in the grid.

I had to post this in 2 posts, (if this works), because forum keeps giving me bad language errors (but won't tell where the bad language is), and won't let me post with my code. forum also keeps putting slashes (\) before all the apostrophes in the message im trying to post.

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 30th Dec 2005 22:58 Edited at: 30th Dec 2005 23:07
*edit* sigh still can't get my code to post properly, still the bad language thing... gonna try to post it in Code Section of posting box, so that it will come up as "Source" at bottom right of my post, sorry

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 30th Dec 2005 23:07
Here ya go

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Dec 2005 08:13
It's messing up because you have a funcion call for the function it's already in (all the keypress functions).

It's better to put the keys in an array and detect the keystate with a for/next loop. You can also use a "case" statement to do different things.




Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 31st Dec 2005 09:25
Thx! i'll try it out, and post my findings in here.

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 31st Dec 2005 10:56
I've tried it, can't find a way to code the function so that after it tests the first (bottom) box in a column, it will go to the next box above it until it gets to the top of the column. At that point, the function should terminate until the key is pressed again.

Looking at my code, if anyone has any ideas please help, been stuck trying to get this to work for hours. Would like to move onto the function that will dynamically assign a type to the box, which will in turn decide whether the box gets hit by the hitChecker() function. i'm suuure that'll be fun to code lol

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Dec 2005 23:24
How does your code look right now?


Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 31st Dec 2005 23:41
code is attached as Source again... Y the heck does it keep saying that my messages have bad language!; it must be something in my code because the text part of all my posts can be submitted without problems. If possible would be nice if forums could tell the users exactly what phrase or word, whatever, is bad language so it would be easier to post. Or, is the bad language error message just a default error that comes up if a post is too large or something?

Anyway, I only test for the a key; i fig if i can get it to work properly for the a key, then i\'ll be able to adjust the same code to work for the other keys.

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Jan 2006 00:10
It's very hard to see whats going on with your code. I think the main thing is your making it confusing (for yourself too) by having two sets of data.

One as a UDT for all the object data and regular arrays for column data. You use the colomn arrays to check if it's been hit... but the UDT data is what records if it's been hit. When it runs again because the column data hasn't been changed it registers the same one being hit over and over again.

You either need to take out the column data and work directly with the UDT data (which I recommend)... or take out the UDT data and make it all a regular array.


Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 1st Jan 2006 00:12
re: bad language

glancing at your source, the last 4 letters of your Function starting with "CellIs..." is probably what's triggering the Bad Language alarm.

My Modest System:
Athlon XP1800+, Windows XP+SP2, Soyo K7V Dragon+ MB, 1.5Gb 333 RAM, ATI Radeon 8700LT (128Mb), Drivers and Updates Kept Current
Gyrich
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: Here, obviously.
Posted: 1st Jan 2006 00:35
LOL thank you Virtual Nomad for finding that, you're probably right although i haven't had to post any code yet. Grog, thank you for all of your help thus far, i'll try working with the UDT only.

One question Grog: Do you think I should dim the array for the grid as a 2 dimensional grid with 8 spots each (i.e.- dim Grid(8,8)) or leave it the way it is as a 1 dimensional grid with 64 slots? why or why not?

I'm about to start this project over from scratch, so I'll let you guys know how it turns out. thx

DBPro User
PC: WinXP, 80gb HD, Nvidia GeForce FX 5200 (128mb onboard RAM), 512mn DDR400 RAM. Thank you for your help.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 1st Jan 2006 00:54
Quote: "Grog, thank you for all of your help thus far, i'll try working with the UDT only."


Np.

Quote: "One question Grog: Do you think I should dim the array for the grid as a 2 dimensional grid with 8 spots each (i.e.- dim Grid(8,8)) or leave it the way it is as a 1 dimensional grid with 64 slots? why or why not?"


Well it seems like that would be good because you only use integers in your UDT... but it should stay as a UDT because you may want to add other things to the UDT (like strings or change integers that won't go over 255 to bytes instead).


Login to post a reply

Server time is: 2024-09-24 11:26:42
Your offset time is: 2024-09-24 11:26:42