Jump to content
IGNORED

on x gosub into a loop


swapd0

Recommended Posts

Quote
enemy_ia
  for i = 0 to 7
    a = enemy_state
    on a gosub _egg, _hatch, _born
  next.
  return
_egg
  return
_hatch
  return
_born
  return

How can I make this work?, I have also tried with on ... goto and then jump before the next but it doesn't work.

 

Thanks

Link to comment
Share on other sites

This way I get no errors

 

Quote
enemy_ia
for i = 0 to 7
a = rand;enemy_state
if a = 0 then gosub _egg : goto _loop_ia
if a = 1 then gosub _hatch : goto _loop_ia
if a = 3 then gosub _born : goto _loop_ia
; on a goto _egg, _hatch, _born
_loop_ia
next
return
_egg
return
_hatch
return
_born
return

 

Link to comment
Share on other sites

16 minutes ago, CloakeD said:

In your first example is the (.) after next in your source code?

No, it was a typo

 

Also, why this doesn't work?

  if yenemy[i] = 16*8 then enemy_state[i] = STATE_MOVE

but this works

  a = yenemy[i]
  if a = 16*8 then enemy_state[i] = STATE_MOVE

 

Link to comment
Share on other sites

49 minutes ago, swapd0 said:

No, it was a typo

 

Also, why this doesn't work?


  if yenemy[i] = 16*8 then enemy_state[i] = STATE_MOVE

but this works


  a = yenemy[i]
  if a = 16*8 then enemy_state[i] = STATE_MOVE

 

I'm not 100% sure here, but I think 7800Basic can't test an array value directly against an array value so you need to load your first value into a temp variable, which you have done in the second example. (more or less - There might be a more technical explanation but that's how I understand it).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...