Jump to content
IGNORED

[bB Help] Score progression makes enemies faster


Itchy_Nipples

Recommended Posts

Hey guys, I've made a generic shooter, you control a ship at the bottom of the screen, an enemy sprite will come down, you fire at it, get a point if you kill it, pretty basic stuff, but for the first game it's something to learn the basics. So far I'm having trouble implementing a feature that I'd like to add. Every 100 points or so, I'd like to see the enemy sprite get faster and faster, to add some difficulty.

 

Here's the code I have having the enemy chase the player:

 if player1y < player0y then player1y = player1y + 1
 if player1y > player0y then player1y = player1y - 1
 if player1x < player0x then player1x = player1x + 1
 if player1x > player0x then player1x = player1x - 1

Now that code worked and I'd like to add some difficulty (faster enemies after so many points) -- Here is what I tried and it didn't work:

 if score < 100 then player1y < player0y then player1y = player1y + 1
 if score < 100 then player1y > player0y then player1y = player1y - 1
 if score < 100 then player1x < player0x then player1x = player1x + 1
 if score < 100 then player1x > player0x then player1x = player1x - 1


 if score > 100 then player1y < player0y then player1y = player1y + 2
 if score > 100 then player1y > player0y then player1y = player1y - 2
 if score > 100 then player1x < player0x then player1x = player1x + 2
 if score > 100 then player1x > player0x then player1x = player1x - 2

In theory this should've worked, but it didn't. I've tried other miscellaneous things but this is the major change I've made. Is there something I'm missing? Any help about this would be highly appreciated.

Link to comment
Share on other sites

I think you just need to replace "then" with "&&". Both conditions need to happen in order for the player to speed up.

 

if score < 100 && player1y < player0y then player1y = player1y + 1
if score < 100 && player1y > player0y then player1y = player1y - 1
if score < 100 && player1x < player0x then player1x = player1x + 1
if score < 100 && player1x > player0x then player1x = player1x - 1


if score > 100 && player1y < player0y then player1y = player1y + 2
if score > 100 && player1y > player0y then player1y = player1y - 2
if score > 100 && player1x < player0x then player1x = player1x + 2

if score > 100 && player1x > player0x then player1x = player1x - 2

Link to comment
Share on other sites

score is a three byte, six decimal (BCD) digit variable.

the bytes are in reverse order, the least significant byte

has the highest address

 

try this

 

edit: oops (fixed)

 rem  give the second byte of the score a name 
 dim scr_hundreds = score + 1
 
if player1y < player0y then player1y = player1y + scr_hundreds + 1
if player1y > player0y then player1y = player1y - scr_hundreds - 1
if player1x < player0x then player1x = player1x + scr_hundreds + 1
if player1x > player0x then player1x = player1x - scr_hundreds - 1
Edited by bogax
  • Like 1
Link to comment
Share on other sites

I'm probably implementing this wrong into my code, but I'm getting a compile error:

DASM V2.20.07, Macro Assembler (C)1988-2003
      bytes of ROM space left
      2094 bytes of ROM space left
      2094 bytes of ROM space left
--- Unresolved Symbol List
scr_hundreds             0000 ????         (R )

Fatal assembly error: Source is not resolvable.
Errors were encountered during assembly
Link to comment
Share on other sites

 

I'm probably implementing this wrong into my code, but I'm getting a compile error:

DASM V2.20.07, Macro Assembler (C)1988-2003
      bytes of ROM space left
      2094 bytes of ROM space left
      2094 bytes of ROM space left
--- Unresolved Symbol List
scr_hundreds             0000 ????         (R )

Fatal assembly error: Source is not resolvable.
Errors were encountered during assembly

 

post your code

 

you can also refer to the second byte of score as score[1]

so you could try something like this

 
temp1 = score[1] + 1
if player1y < player0y then player1y = player1y + temp1
if player1y > player0y then player1y = player1y - temp1
if player1x < player0x then player1x = player1x + temp1
if player1x > player0x then player1x = player1x - temp1
Edited by bogax
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...