Jump to content


Photo

Is My Understanding Of Gosub Correct?


  • Please log in to reply
3 replies to this topic

#1 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 27 January 2004 - 02:11 AM

1. A GOSUB is the same thing as a GOTO only at the end of it (the gosub section you just went to) you put RETURN which takes you back where you came from.?

Is this right, cause I was examining the tetris.xas and I looks to me like that's how it's used.

2 Is there a way for me to assign both x and y coordinates to one varible? If so how should I go about doing it?

#2 BenJeremy

BenJeremy

    X-S Elysian

  • Head Moderators
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 9,690 posts
  • Gender:Male
  • Xbox Version:v1.1
  • 360 version:v1 (xenon)

Posted 27 January 2004 - 02:20 AM

1. You are correct. GOSUB allows you to set up local subroutines.

2. ?? I don't know why you'd want to do this.

#3 flattspott

flattspott

    X-S Freak

  • Moderator
  • PipPipPipPipPip
  • 1,787 posts
  • Location:Southern California
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 27 January 2004 - 03:16 AM

Okay, let me clarify numer 2 for you.

What I want to do is have a box act as a cursor of sorts. Depending on where it's at on the screen, when you press a button it causes another box underneath it to colorize if you will. I can't use only one coordinate cause if there are multiple rows and columns of possible blocks to be colorized it won't work.

#4 Kthulu

Kthulu

    X-S Freak

  • XS-BANNED
  • PipPipPipPipPip
  • 1,287 posts
  • Xbox Version:v1.0
  • 360 version:unknown

Posted 27 January 2004 - 04:26 AM

if i understand you correctly, sounds kinda similar to how my virtual keyboard works. you can draw your 'box cursor' like this...

BOX %x% %y% 25 25 BLACK WHITE

when the D-pad right is pressed...

ADD x 25

D-pad left is pressed...

SUB x 25

D-pad down is pressed...

ADD y 25

D-pad up is pressed...

SUB y 25

...of course, you'll have to check for those special cases where you don't want the 'box cursor' to move any more in a certain direction...

drawing a different colored box at the same location of the box cursor when you press A (or whatever button) isn't a problem either, but getting the script to remember where to draw the 'selected' boxes after you move your 'box cursor' is. you'll prolly need some data structure to hold on/off information. will the number of possible 'selected boxes' be known before hand?

if there are only 10 possible 'selected boxes' you could have a string of ten 1s and 0s...1 meaning to draw the box, 0 meaning don't draw the box. of course, it sounds like you could use the new [] {} variable referencing for an array too. translating the 1 or 0 to a coordinate is simply a matter of math and how you want the 'selected boxes' arranged.

if your 'selected boxes' are in 2 rows of 5 each and your on/off info looks like this... "0010000000"
1 is in the 2nd position of the string (0th being the first position), so...

SelX = 2 * 25 (25 being the width of your boxes)
SelY = (2 / 6 ) * 25 (25 being the height of your boxes) (in actionscript, 2 / 6 = 0)

for "0000000010" (1 being in the 8th position in the string)

SelX = 8 * 25
SelY = (8 / 6) * 25 (8 / 6 = 1 in actionscript)

ok, this post is getting long and i should be going to bed smile.gif i hope i understood your desires and i hope didn't tell you something you already knew. i hope i actually made sense too, but if i didn't...have a look at the actionscript code of my virtual keyboard (it's on AXS). if that doesn't help, i'd be glad to help in PMs with pieces of your code smile.gif

if i'm still no help, i'll be glad to see someone else help smile.gif

Edited by Kthulu, 27 January 2004 - 04:31 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users