Jump to content
abaudrand

little problems with if-then and maths

Recommended Posts

Hi, I'm trying to do a checktest to determine the movement of the missile of one player depending the position of the other player.

I wrote that:

 

if player1y-player0y<30 then var6{1}=0 else var6{1}=1

 

but it will not compile. I guess I got a kind of 'syntax error'.

Do I need to broke the operation like:

 

temp2=player1y-player0y

if temp2<30 then var6{1}=0 else var6{1}=1

 

What do you think?

Share this post


Link to post
Share on other sites

okay, I'll try tommorow. I hoped it could save a line of code... Thanks RT.

I don't try to do math in an if-then. I use a temporary variable like in your second example.

Share this post


Link to post
Share on other sites

if player1y-player0y<30 then var6{1}=0 else var6{1}=1

I'm able to compile that line of code without an error, so I think there must be something else wrong with your program. What makes you think it's in that line? What does the error message say?

 

Michael

Share this post


Link to post
Share on other sites

When I try to do the maths inside the if-then statement, the compilation stops at this line:

 

.L0784 ; if player1y - player0y < 30 then var6{1} = 0 else var6{1} = 1

 

LDA player1y

CMP player0y

.skipL0784

.condpart344

 

But when I broke into two part the code, it works fine:

 

.L0784 ; temp2 = player1y - player0y

 

LDA player1y

SEC

SBC player0y

STA temp2

.L0785 ; if temp2 < 30 then var6{1} = 0 else var6{1} = 1

 

LDA temp2

CMP #30

BCS .skipL0785

.condpart344

LDA var6

AND #253

STA var6

jmp .skipelse10

.skipL0785

LDA var6

ORA #2

STA var6

.skipelse10

 

For the moment, I will keep it broken in two parts even I don't understand why it doesn't work :)

Regards.

Share this post


Link to post
Share on other sites

if player1y-player0y<30 then var6{1}=0 else var6{1}=1

I'm able to compile that line of code without an error, so I think there must be something else wrong with your program. What makes you think it's in that line? What does the error message say?

 

Michael

I think compiling it requires this build of bB.

Share this post


Link to post
Share on other sites

:/ I don't know if I should use this build of bB as long as it's not an official upgrade... Since I've switched to SC, I got more free variables available and I could burn one or two for storing figures for mathematical operations. I must agree this new build could spare them and I also guess it could spare cycles... icon_question.gif(mumbling)

Share this post


Link to post
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.

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...