Jump to content
Sign in to follow this  
TheCoffeeFox

Making Levels? Need Help

Recommended Posts

Hi Again! I'm still in the makes for a little game but i need help i had a idea of after getting like 20 points from shooting monsters it could goto a other level and if so could i make it have more monsters spawn

 

I was wondering if this line of code would work

 

if score = score+20 then goto level2

 

and then a Playfield called level2 i created would load please tell me if that would work and if it would how can i make 1 more monster load?

 

Thanks!

Share this post


Link to post
Share on other sites

No, that won't work, because the "if" statement is looking for equality between both sides of the equal sign, in this case "score" and "score+20".

You could try something like:

 

level=score/20

if level=1 then goto level2

 

First of all, I'm not familiar with batari basic specifically, so I don't know if that syntax is correct. I'm using "/" as division.

Second of all, I'm assuming the variable "score" is an integer, so that 19 divided by 20 is zero, but 20 divided by 20 is one.

Edited by 5-11under
  • Like 1

Share this post


Link to post
Share on other sites

Second of all, I'm assuming the variable "score" is an integer, so that 19 divided by 20 is zero, but 20 divided by 20 is one.

It's not, so this probably won't work as expected. In batariBasic, score is actually 3 BCD bytes, which means that the bytes go from $00 to $99 and each of those hex nybbles is read like the decimal digits 0-9. However, if you tried to divide them, you wouldn't get the same result:

 

99 / 2 = 49.5

$99 / 2 = 76.5

Edited by Cybearg
  • Like 1

Share this post


Link to post
Share on other sites

Yeah. I'd avoid using score for anything but displaying the score. It gets complicated and fussy real fast.

 

Instead, I'd, say, use a variable to count how many monsters you've killed to determine when to go level 2.

 

_rem /** Determine if the players laser has hit a monster and chalk up another monster kill **/

_if collision(missile0, player1) then monsterskilled = monsterskilled + 1

_rem /** If the player has killed 20 monsters start the routine for level 2 **/

_if monsterskilled = 20 then goto level2

  • Like 1

Share this post


Link to post
Share on other sites

How do I set monsters to not give me errors putting monsterskilled just give me black screen how do I set the setting?

In that example, monsterskilled is just an arbitrary name for a variable. You set variables like so:

dim monsterskilled = a

Typically, people define all their variables like that before any code. The "dim" just means that you're defining a name for some memory. a-z are the names of variables that have been made available to you in batariBasic.

 

Think algebra. Just like you can write a + b = c, you could also write monsterskilled + tummiestickled = laughsgiven, or any other combination of words. It's just a name to represent the number in an abstract way.

 

All you need to do is let the compiler know what those words (variables) refer to, which is what the "dim" statement is for. That's why you were getting a black screen: the compiler didn't know what "monsterskilled" meant.

Edited by Cybearg

Share this post


Link to post
Share on other sites

Im Sorry Im Having trouble where do I put level2 playfield before titlescreen or after it and before level1 or after level 1?

Typically, titlescreen logic is separate from level logic, so while it doesn't actually matter, most likely people will go titlescreen->level 1->level 2, etc. for the sake of semantics.

 

If you haven't already, I'd recommend reading through RandomTerrain's excellent batariBasic documentation and checking out the examples.

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.
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...