Confused.... Help Please!


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Well I am already doing that with the array, the problem lies somewhere in updating the array and continuing the scrolling of the numbers across the lcd from where i left off..

    I'm not sure how to go about it since the numbers need to go from right to left with new 1's adding on the far right and removing on the far left without disrupting the current position of the other numbers while doing so

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    I have gone and played the game you linked, it is exactly as I remember it! great find, Thank you.

    OK on to business here. What I understand of your description seems different then how the game works. heres what I think you are trying to do. You only want to allow the player to shoot the first (or last) number in the line? This will make it VERY hard to play. But maybe thats not what you mean.

    Heres what I assumed you wanted to do, If here are 3 sevens in the display, every time i hit fire with my aim number being 7, it will remove the left most occurance of the 7. Then any numbers further to the left will move right. In that way, if the player has 3 sevens, and can press fire 3 times before a new number is added, the targets are now fewer. The orginal game had a preset number of targets to shoot for each level. When all were shot without letting them reach the : level was complete. next level, numbers appear faster.

    so here is what I am trying to suggest:
    assume we have only 5 elements in the array (make bigger to suit your game but the theory will be the same)

    t(0) t(1) t(2) t(3) t(4) t(5) #t(5) is the : if t(5) <>" ", you lose

    upon starting the game t(all) = " "
    when a new number is added, it comes in at t(0). to do this, first shift everybody right, maybe like this:
    t(5)=t(4)
    t(4)=t(3)
    t(3)=t(2)
    t(2)=t(1)
    t(1)=t(0)
    t(0)=new target
    if t(5)<>" " you lose

    update LCD

    now for the fire check:
    scroll through the array checking for equal:

    index=4
    start check
    if t(index)<>bullet
    index=index-1
    if index<0 then no hit
    goto start check
    else hit
    now lets say t(2) = bullet

    for shift = index to 4
    t(shift)=t(shift+1)
    next shift

    now update LCD with new array!
    wait in mainloop until either aim is pressed, fire is pressed or scroll timer says add a number

    I purposely did not put use code tags because I am not sure this would be compilable code. I am new to PBP and don't have all the syntax in my head yet. I am really just trying to show you ONE way of approaching this. Of course a loop would be much better for the shift, and I'm sure I have left plenty of stuff out, but maybe this will help.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    I was unsure as to whether or not you could only shoot down the front number or any number in the line, so long as the number was equal to the target of course.

    The problem I am having is actually getting the nubers to scroll across the LCD you see i have a 2 x 16 LCD running on port.B 4 buttons below it running on Port.A 0-3 the 627 and the required resistors etc (my dad built it specifically for this project)

    The code I originally found for scrolling text across the screen was this

    Code:
      FOR B0 = 144 TO 128 STEP -1
      LCDOUT $FE, 1  ' Clears Screen (not needed)
      LCDOUT $FE,B0,"This Is A Test!!"          'OUTPUT TO LCD SLIDE
      PAUSE 1000                                         'IN FROM RIGHT LINE 1
      NEXT
    The above code simply steps the string in 1 character at a time from the far right of line 1 until it reaches the far left.

    Of course this is using a predefined string and isnt suitable for what I need to be doing, since I need to be bringing them in from the right while removing characters from it and maintaining the position of the existing numbers.

    If how you describe the game being played is actually as it was (similar to the clone I linked)
    then if the below example occured I would need to do the following

    5: 4385559271 ---> 5: 438 9271 and continue adding onto the end and shifting the characters from right to left, at the same time I need to be checking to see if a number has reached the ship... I was thinking of possibly using LCDIN on the cell after the "5:" and checking to see if it had a number in it during the loop which adds another.

    This would of course allow me to determine whether or not the player is out, since if a number is in that cell and another is being added then it would hit the :

    I just dont know how to get them to scroll and remove numbers in between without losing positioning like the example above, I am terrible when it comes to overcomplicating and thus need a little advice for an approach.

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by UKIkarus View Post
    5: 4385559271 ---> 5: 438 9271
    It would go from 4385559271 -->4389271. No space in it.

    Don't think of scrolling the display. Think of your array like this:

    If I have 31 positions for the numbers, They will be T(30) to t(0)
    each "scroll" is really just an update to the LCD, sending array positions T(30)-T(0)
    with all the elements shifted 1 place to the left. (new targets enter from the right?)
    you will be able to do MANY operations before time to scroll again. Those many operations are the checking for hits, adjusting the array and so forth.

    Keep this in mind, assuming you are running 4mHz internal clock (no I haven't looked at the datasheet) thats 1 million inscrutions per second. if you want to scroll at a rate of .1 second, you have time left over for 100,00 inscrutions. So the "scrolling" is just a quick task, then done.

    Now I have no idea how to actually write to the LCD, but I am assuming you just send it all the characters serially and not address each charater randomly. So your array may need to be 64 bytes instead of 32.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Sep 2010
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cncmachineguy View Post
    It would go from 4385559271 -->4389271. No space in it.

    Don't think of scrolling the display. Think of your array like this:

    If I have 31 positions for the numbers, They will be T(30) to t(0)
    each "scroll" is really just an update to the LCD, sending array positions T(30)-T(0)
    with all the elements shifted 1 place to the left. (new targets enter from the right?)
    you will be able to do MANY operations before time to scroll again. Those many operations are the checking for hits, adjusting the array and so forth.

    Keep this in mind, assuming you are running 4mHz internal clock (no I haven't looked at the datasheet) thats 1 million inscrutions per second. if you want to scroll at a rate of .1 second, you have time left over for 100,00 inscrutions. So the "scrolling" is just a quick task, then done.

    Now I have no idea how to actually write to the LCD, but I am assuming you just send it all the characters serially and not address each charater randomly. So your array may need to be 64 bytes instead of 32.
    So would you shift the 438 right to meet the 9271 or the opposite? because if its the opposite then it isnt really helping the player by shooting the middle numbers now is it? since they continue to be in the same position and will just keep adding on... unless of course they then shoot the front numbers

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by UKIkarus View Post
    So would you shift the 438 right to meet the 9271
    Yes, that way the player keeps the targets from hitting the ship.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default new approach

    Ok, Lets establish some basics first.

    In your first post, you have a program that scrolls numbers across the screen at a rate of 1 sec per number. correct?

    You are reading the numbers from an array, correct?

    So if you take out the pause, it will just instantly display the whole array? If yes, this is your LCD update. call this every time you need to change the display.

    reasons to update or change:
    1. time to scroll
    2. aim button pressed so you need to change the aim number
    3. fire button pressed AND a hit is made

    Now you can forget about the LCD. when you update it, send all 32 characters to it (unless random access is available, but this will take more code and understanding). The game portion of the program will minipulate the array so everytime in update is done, the numbers will be where they should be. Because they will be in the same position as they are in the array.

    If none of this makes sense, please tell me where you are lost. This applies to all of my above posts.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts