Author Topic: Can someone help with this bug?  (Read 4385 times)

0 Members and 1 Guest are viewing this topic.

_player1537

  • Guest
Can someone help with this bug?
« on: May 31, 2010, 04:36:00 pm »
I'm trying to make an asteroids game, but I keep running into wierd errors, can anyone help.  Basically what should happen is this: as you move around it will give you acceleration and you slow down gradually, but when you move to the left, it starts freaking out.  I threw in a test so that when it triggers the "Too far left" code, it inverts the screen.  The problem is, you move too far left every time you move left at all.  Here's my code.  I'm using the latest axe as well.
Code: [Select]
:.B
:[18183C3C3C000000020F1E0E0400000000001C1F1F1C0000000000040E1E0F02→Pic1
:[0000003C3C3C1818000000207078F040000038F8F838000040F0787020000000
:[0000001818000000→Pic2
:[0000183C3C180000
:0→X→Y
:0→T→S
:Pic1→D
:0→B
:Repeat getKey(15)
:If getKey(2)
:6→B
:End
:If getKey(3)
:2→B
:End
:If getKey(4)
:0→B
:End
:If getKey(1)
:4→B
:End
:If getKey(4) and getKey(2)
:7→B
:End
:If getKey(2) and getKey(1)
:5→B
:End
:If getKey(3) and getKey(4)
:1→B
:End
:If getKey(3) and getKey(1)
:3→B
:End
:If getKey(54)
:S+(getKey(3)-getKey(2)*2)→S
:T+(getKey(1)-getKey(4)*2)→T
:End
:Pt-Off(X/256,Y/256,B*8+Pic1
:If getKey(54)
:If (B=1) or (B=3) or (B=5) or (B=7)
:Pt-On(X/256,Y/256,Pic2
:Else
:Pt-On(X/256,Y/256,Pic2+8
:End
:End
:S/2+X→X
:T/2+Y→Y
:If S
:If S<<0
:S+1→S
:Else
:S-1→S
:End
:End
:If T
:If T<<0
:T+1→T
:Else
:T-1→T
:End
:End
:If X<<0
:DrawInv
:X+22528→X
:End
:If X>>22528
:X-22528→X
:End
:If Y<<0
:Y+14336→Y
:End
:If Y>>14336
:Y-14336→Y
:End
:
:DispGraph
:End
:Return:Lbl AA:For(A,0,1):For(B,0,1):Pt-Change(8*B+X,8*A+Y,2*A+B*8+D):End:End

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Can someone help with this bug?
« Reply #1 on: May 31, 2010, 04:44:31 pm »
Code: [Select]
:If S
:If S<<0
:S+1→S
:Else
:S-1→S
:End
:End
:If T
:If T<<0
:T+1→T
:Else
:T-1→T
:End
:End

These lines of code bug me. What if S or T equal 0?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







_player1537

  • Guest
Re: Can someone help with this bug?
« Reply #2 on: May 31, 2010, 04:46:41 pm »
then they won't get touched, the first If S line makes sure it is not zero the same with If T
« Last Edit: May 31, 2010, 04:46:58 pm by _player1537 »

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Re: Can someone help with this bug?
« Reply #3 on: May 31, 2010, 04:54:01 pm »
Why did you inflate S and T by a factor of 2?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







_player1537

  • Guest
Re: Can someone help with this bug?
« Reply #4 on: May 31, 2010, 04:55:37 pm »
because I deflate S and T by 1 each time, that way it can get faster and faster the longer you hold the buttons, and then die down later.  I could fix that another way, I might do that later

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Can someone help with this bug?
« Reply #5 on: May 31, 2010, 06:11:18 pm »
I think you need to do S//2 and T//2, because they are signed values.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

_player1537

  • Guest
Re: Can someone help with this bug?
« Reply #6 on: May 31, 2010, 06:13:28 pm »
Oh!  thank you!  yes, that was the bug, I completly forgot about the signed division routine.

_player1537

  • Guest
Re: Can someone help with this bug?
« Reply #7 on: June 02, 2010, 05:06:39 pm »
Here is the code I was working with, if anyone wants to use this (even for the contest) go for it.  Just figured I'd post it since I'm not going to work on it anymore.  The group might be corrupted...

Edit:  TILP output a .8Xgrp file, I changed it to that in hopes it would work with SC...it didn't
« Last Edit: June 02, 2010, 05:07:26 pm by _player1537 »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Can someone help with this bug?
« Reply #8 on: June 02, 2010, 11:36:45 pm »
Sorry to hear you won't be working on it again anymore :(

_player1537

  • Guest
Re: Can someone help with this bug?
« Reply #9 on: June 02, 2010, 11:39:46 pm »
eh, I've got other things to work on...and I know what I'm making for the contest now (between two things, although its probably the one me and SIr are having a competition (friendly competition) about :D )

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Can someone help with this bug?
« Reply #10 on: June 02, 2010, 11:43:24 pm »
yeah I understand x.x