Author Topic: fx-9860GII; inefficient coding?  (Read 5566 times)

0 Members and 1 Guest are viewing this topic.

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
fx-9860GII; inefficient coding?
« on: January 20, 2011, 08:10:53 am »
I'm creating a simple maze-like game on my fx-9860GII, but there's one thing taking a huge amount of data and time. The goal of the game is to move a dot (.) between the crosses (X) towards the exit (O). There are also fake exits (looks exactly the same as a real exit). Touching a cross or fake exit adds 1 to the death counter (which decreases your score after completing all of the levels by 2500 per death) and resets the level. Every step you take also decreases 100 from your final score.

The problem is not the positioning of the crosses, (fake) exits and the dot, but the death system is. Level 1 and 2 are respectively 3220 and 5344 in size. They just contain this bit of code, repeated over and over again:

(Everything between {} is either a command I can't type or a number that differs throughout the code and [] are comments)

Spoiler For Spoiler:
If X={x-coordinate of cross/fake exit}          [Determines the x-coordinate of the cross/fake exit]
Then If Y={y-coordinate of cross/fake exit}            [Determines the y-coordinate of the cross/fake exit]
Then ClrText                                                      [Clears the screen]
Locate 7,2,"YOU DIED"{disp_command}                  [Displays "YOU DIED" text]
D+1-->D                                                           [Adds 1 to the death variable]
Prog "LEVEL1"                                                    [Restarts the level]
IfEnd                                                                [Ends the x-coordinate If-statement]
IfEnd                                                                [Ends the y-coordinate If-statement]

I was wondering whether there is a more efficient way to do this instead of repeating this (with variations for completing the level and hitting a fake exit). I'm asking because I also recently learned how to get rid of the tracks the dot leaves behind without being required to draw all of the crosses and (fake) exits again per step.

Thanks in advance!
« Last Edit: January 20, 2011, 09:05:14 am by sjasogun1 »
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: fx-9860GII; inefficient coding?
« Reply #1 on: January 20, 2011, 12:06:19 pm »
Well, you could just do

Code: [Select]
If (x={})(y={}
Then ClrText
Locate 7,2,"YOU DIED"
IS>(D
Prog "Level"
IfEnd
« Last Edit: January 20, 2011, 12:07:42 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Re: fx-9860GII; inefficient coding?
« Reply #2 on: January 21, 2011, 04:16:05 am »
It helps a bit, but I meant: is there any way to get all of the combinations of x and y coordinates in a single command?
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Re: fx-9860GII; inefficient coding?
« Reply #3 on: January 26, 2011, 04:08:38 am »
Never mind, I found out already. The easiest way is to use (X={} AND Y={}) OR (X={} AND Y={}) multiple times, so you can get all of the possible death locations in one if-statement.

Problem solved, topic locked.
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901