Author Topic: Lights Out help?  (Read 12596 times)

0 Members and 1 Guest are viewing this topic.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Lights Out help?
« on: November 29, 2013, 02:01:21 pm »
I need help with adding a selection box to this code (basically, I want a white box around the square selected). I know what I want, but try as I might, I can't do it! And the fact that the keys are so sensitive (and repeat) don't help, either.

The tries I did for adding it in either have it not move, have it be black and not moving right, or having it (apparently) go out of bounds. I thought I did it right, but it just doesn't work! What can I add to this code to make that? I can probably figure out the ENTER pressing light change afterwards.

Code: [Select]
.LIGHTOUT
ClrDraw rr
DrawInv
DrawInv r
[00C0F0FCFEFEFFFF]→Pic1
[FFFFFFFFFFFFFFFF]→Pic2
[0000000000000000]→Pic3
0→C
Repeat C
For(X,0,5
For(Y,0,5
Pt-Off(9*X+1,9*Y+1,Pic3
Pt-Off(9*X+1,9*Y+1,Pic1)r
If rand^2
Pt-On(9*X+1,9*Y+1,Pic2
C+1→C
End
End
End
End
Repeat getKey(15)
DispGraph rr
End
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Lights Out help?
« Reply #1 on: November 30, 2013, 08:56:16 am »
And the fact that the keys are so sensitive (and repeat) don't help, either.
About that, you can add a delay or even some simple debouncing code such as :
Code: [Select]
While 1            .More optimised than While getKey(0)
Pause 5            .Necessary for it to work, else it would loop so fast that it wouldn't detect any key presses and thus be useless
End!If getKey(0)   .See first line
It should do the trick. ;)
« Last Edit: November 30, 2013, 08:57:57 am by Streetwalker »

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #2 on: November 30, 2013, 11:45:19 am »
Where exactly would I put that in the code?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Lights Out help?
« Reply #3 on: November 30, 2013, 11:45:58 am »
Right after your input code.
« Last Edit: November 30, 2013, 11:46:11 am by Streetwalker »

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #4 on: November 30, 2013, 11:57:45 am »
I'll tweak the code accordingly. Thanks!

I'll get back to you when it's done.

EDIT: The motion code works well, but apparently the debounce code given made the grayscale look weird when I was pressing buttons at all. I'll try to tweak THAT.

EDIT 2: I can't figure out another debounce code! Can anyone give me a debounce routine for use with 4 level grayscale?

EDIT 3: Never mind, Xeda Elnara made one for me. Here it is:
Code: [Select]
getKey -> A
If A=B
0 -> A
Else
A -> B
End

And you use B=code instead of getKey(code).

I'll be sure to credit her. Also, I'm working on the light toggling and wincheck. Soon, I'll post the code!

EDIT 4: The source is attached. I will add a win message, a title screen, and everything else to make this "presentable" later, but I at least want optimization for this part. Can someone optimize this code? I'm using the latest version of Axe Parser.
« Last Edit: November 30, 2013, 04:51:07 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Lights Out help?
« Reply #5 on: November 30, 2013, 04:27:48 pm »
Not him, her. Xeda is a girl. Other than that, yes it works but it is much slower. The reason why my debounce code messes up greyscale is that it stops the program until you release every key. Hence greyscale is not shown anymore. An option would be to move the DispGraph^^rr in the loop I gave you and remove the Pause 5 because it's not needed anymore. ;)
« Last Edit: November 30, 2013, 04:28:17 pm by Streetwalker »

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #6 on: November 30, 2013, 04:49:17 pm »
Sorry, HER. I keep forgetting she is a girl. :-\

Anyways, that's actually EXACTLY what I want. I just want it so that if a button is pressed, it doesn't repeat the action (and if it does, as for the arrow keys with this method, not very fast. :D)

EDIT: Also, does the Text command HAVE to be inside the loop for it to display text in the current situation? Because I just added it outside of the loop in the version still on my calc, and the text keeps getting erased.
« Last Edit: November 30, 2013, 04:52:55 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Lights Out help?
« Reply #7 on: November 30, 2013, 04:56:30 pm »
Yes you need it in the loop because you erase the whole thing every time. And text draws directly to the screen, not the buffer so you have to look at the fix command.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #8 on: November 30, 2013, 05:01:58 pm »
Fix 5, you are my hero! :D

Well, now to add the fancy stuff.

Also, Can somebody optimize my code?
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Lights Out help?
« Reply #9 on: November 30, 2013, 05:03:26 pm »
Please be specific about what you want us to optimize and for size or speed ? Also do a bit of research about it in the Axe forum. It's good to know how to do it yourself. ;)
« Last Edit: November 30, 2013, 05:03:52 pm by Streetwalker »

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #10 on: November 30, 2013, 05:09:53 pm »
Size. The speed is adequate. And sorry, this is my first ACTUAL endeavour in Axe.

EDIT: Never mind, the Rect and RectI commands are providing many chances for optimizations. I'll get back to you.

EDIT 2: Now the size of the compiled result is 1,767 bytes. Code tomorrow, along with some other stuff for an in-game sidebar.
« Last Edit: November 30, 2013, 06:38:24 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Lights Out help?
« Reply #11 on: November 30, 2013, 07:54:34 pm »


This is pretty cool! +1

Here's one thing you can optimize: instead of A+1->A use A++
« Last Edit: November 30, 2013, 07:57:49 pm by ClrDraw »
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #12 on: November 30, 2013, 08:16:19 pm »
I did in the source already, just figured out that trick. Also, I made an optimized version, so change the screenie. (Looks cool, though!)

The source is attached.

Oh, and the black squares are lights "on", and the white squares are lights "off". Just looked like you thought the opposite.

EDIT: Uhhhh...SHOULD it be the opposite?
« Last Edit: November 30, 2013, 08:17:45 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Lights Out help?
« Reply #13 on: November 30, 2013, 09:01:23 pm »
Haha yeah I think it should probably be the opposite  ;) Also they eye is attracted to lighter colors so people will naturally try removing the white squares.
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline JWinslow23

  • Coder Of Tomorrow
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 556
  • Rating: +43/-6
  • I make quality calculator games...when I have time
    • View Profile
Re: Lights Out help?
« Reply #14 on: November 30, 2013, 09:15:22 pm »
OK, an update is coming tomorrow. Xeda Elnara is now working on whatever optimizations I missed, and in the meantime, I'll give you this to mess around with if you want. It's the Axe source.
If you want, I can make gameplay modes to select, like Lit Only, Toggle, or even choosing the x move instead of the + move! But should I include the puzzles from the original? I don't know if I should, there are literally 900.
« Last Edit: November 30, 2013, 09:22:47 pm by JWinslow23 »
Did you know that "Ammonia Gas" rearranged is "As Omnimaga"?
Click here for the only set of games you'll ever need
= ?