Jump to content
IGNORED

Help a newbie out...


ZippyOasys

Recommended Posts

6 hours ago, ZippyOasys said:

So, i'm getting ready to dip my feet into intybasic, is there easy platforming example code out there?

The default distro and the SDK by @DZ-Jay contains around 20 examples of coding and games.

 

If you know how to use the Windows CMD terminal, or the Mac/Linux Terminal you should have no difficulties.

  • Like 1
Link to comment
Share on other sites

4 minutes ago, nanochess said:

The default distro and the SDK by @DZ-Jay contains around 20 examples of coding and games.

 

If you know how to use the Windows CMD terminal, or the Mac/Linux Terminal you should have no difficulties.


For a platformer, I was thinking of the Monkey Moon example from the book; but yeah, any of the contributed games that come with IntyBASIC or the SDK would be a good start.

 

I believe there is a neat Pac-Man clone in there too (Pak-Pak?).

 

   dZ.

  • Like 1
Link to comment
Share on other sites

4 hours ago, DZ-Jay said:


For a platformer, I was thinking of the Monkey Moon example from the book; but yeah, any of the contributed games that come with IntyBASIC or the SDK would be a good start.

 

I believe there is a neat Pac-Man clone in there too (Pak-Pak?).

 

   dZ.

I don't know how I survived without reading full sentences 😅

 

Indeed the original question asked for a platformer code, and yes, my book Programming Games for Intellivision includes two examples: Monkey Moon and Bouncy Cube.

  • Like 2
Link to comment
Share on other sites

  • 5 months later...
1 hour ago, ZippyOasys said:

Right now, i just want an example of a jumping sprite (MOB). I'll worry about collision detection later.

 

I think Oscar's books include at least one.  There is a "Donkey Kong" clone platformer game in the first book.

 

    -dZ.

Link to comment
Share on other sites

  • 1 month later...

Currently analyzing the "Monkey Moon" code.

 

In the meantime, can someone help me turn these snippets of BatariBasic code into IntyBasic code?

 

Quote

   ;***************************************************************
   ;
   ;  Cube movement right to left (1).
   ;
   if !_Bit4_Ruby_Direction{4} then goto __Skip_Ruby_R_to_L

   _M_x = _M_x - 0.80

   ;```````````````````````````````````````````````````````````````
   ;  Skips if edge not reached.
   ;
   if missile0x > 16 then goto __Skip_Ruby_L_to_R

   ;```````````````````````````````````````````````````````````````
   ;  Sets new cube location and direction if player in air and
   ;  edge reached.
   ;
   missile0x = 139 : missile0y = (rand&31) + 23 : _Bit4_Ruby_Direction{4} = 1

   if player0y < 72 && player0x > 76 then missile0x = 16 : _Bit4_Ruby_Direction{4} = 0

   ;```````````````````````````````````````````````````````````````
   ;  Makes it more random if player on ground.
   ;
   if player0y = 72 && missile0x = 139 then temp6 = rand : if temp6 > 127 then missile0x = 16 : _Bit4_Ruby_Direction{4} = 0

   goto __Skip_Ruby_L_to_R

__Skip_Ruby_R_to_L


   ;***************************************************************
   ;
   ;  Cube movement left to right (0).
   ;
   _M_x = _M_x + 0.80

   ;```````````````````````````````````````````````````````````````
   ;  Skips if edge not reached.
   ;
   if missile0x < 139 then goto __Skip_Ruby_L_to_R

   ;```````````````````````````````````````````````````````````````
   ;  Sets new cube location and direction if player in air and
   ;  edge reached.
   ;
   missile0x = 139 : missile0y = (rand&31) + 23 : _Bit4_Ruby_Direction{4} = 1

   if player0y < 72 && player0x > 76 then missile0x = 16 : _Bit4_Ruby_Direction{4} = 0

   ;```````````````````````````````````````````````````````````````
   ;  Makes it more random if player on ground.
   ;
   if player0y = 72 && missile0x = 139 then temp6 = rand : if temp6 > 127 then missile0x = 16 : _Bit4_Ruby_Direction{4} = 0

__Skip_Ruby_L_to_R

   ;***************************************************************
   ;
   ;  Cube movement right to left (1).
   ;
   if !_Bit1_Cube_Direction{1} then goto __Skip_Cube_R_to_L

   _P1_x = _P1_x - 0.43

   ;```````````````````````````````````````````````````````````````
   ;  Skips if edge not reached.
   ;
   if player1x > 16 then goto __Skip_Cube_L_to_R

   ;```````````````````````````````````````````````````````````````
   ;  Sets new cube location and direction if player in air and
   ;  edge reached.
   ;
   player1x = 143 : player1y = (rand&63) + 15 : _Bit1_Cube_Direction{1} = 1

   if player0y < 72 && player0x > 76 then player1x = 10 : _Bit1_Cube_Direction{1} = 0

   ;```````````````````````````````````````````````````````````````
   ;  Makes it more random if player on ground.
   ;
   if player0y = 72 && player1x = 143 then temp6 = rand : if temp6 > 127 then player1x = 10 : _Bit1_Cube_Direction{1} = 0

   goto __Skip_Cube_L_to_R

__Skip_Cube_R_to_L


   ;***************************************************************
   ;
   ;  Cube movement left to right (0).
   ;
   _P1_x = _P1_x + 0.43   

   ;```````````````````````````````````````````````````````````````
   ;  Skips if edge not reached.
   ;
   if player1x < 139 then goto __Skip_Cube_L_to_R

   ;```````````````````````````````````````````````````````````````
   ;  Sets new cube location and direction if player in air and
   ;  edge reached.
   ;
   player1x = 143 : player1y = (rand&63) + 15 : _Bit1_Cube_Direction{1} = 1

   if player0y < 72 && player0x > 76 then player1x = 10 : _Bit1_Cube_Direction{1} = 0

   ;```````````````````````````````````````````````````````````````
   ;  Makes it more random if player on ground.
   ;
   if player0y = 72 && player1x = 143 then temp6 = rand : if temp6 > 127 then player1x = 10 : _Bit1_Cube_Direction{1} = 0

__Skip_Cube_L_to_R

 

Link to comment
Share on other sites

3 hours ago, ZippyOasys said:

Currently analyzing the "Monkey Moon" code.

 

In the meantime, can someone help me turn these snippets of BatariBasic code into IntyBasic code?

 

 


 

I won't translate the entire code, but here are a few pointers.


   

if !_Bit4_Ruby_Direction{4} then goto __Skip_Ruby_R_to_L
   _M_x = _M_x - 0.80

 

  • There is no support for floating point numbers in IntyBASIC, so you will have to use fixed point and handle the scaling by hand.
  • The symbol "!" represents logical negation.  In IntyBASIC you use NOT, but it would be more efficient if you compared the results to zero.
  • There are no vector variables or direct bit manipulation in IntyBASIC, so you will have to mask the bits yourself and compare against the value, or zero.  Something like:
If (RunyDirection And 4) <> 0 Then

 

  • Variables are 8-bit by default, unless you prefix them with "&" for 16-bit variables.

 

missile0x = 139 : missile0y = (rand&31) + 23 : _Bit4_Ruby_Direction{4} = 1

 

  • Logical  "&&" is "And"
  • Bitwise "&" is also "And"
  • "Rand" works the same, but you could also call it with a range, so you could do instead:
missile0y = Rand(32) + 23 ' A random number from 23 to 54

 

  • You also cannot assign a specific bit to a vector, you need to do it by hand.  Something like this (the "And" is to mask away and clear the bit first, then we set it by adding it in).
RubyDirection = (RubyDirection And (Not 4)) + 4

 


I think you will get more people to help if you ask specific questions.  The syntax of BatariBASIC seems to be slightly different from IntyBASIC and we can help with that, but it may be easier to just specify what you are trying to accomplish and we can offer a suitable way to do it in IntyBASIC.

 

     dZ.

Link to comment
Share on other sites

4 minutes ago, ZippyOasys said:

@DZ-Jay @nanochess is "temp6" in the same intybasic syntax or does it differ from bataribasic syntax?

In IntyBASIC you can make as many variables as required and with any name you want, but obviously every one uses space inside RAM.

 

The internal support subroutines doesn't use any publicly available temporary variable name, so you don't have to worry about crashing the namespace.

 

My personal preference is to use the letter 'c' as a temporary variable, along 'd', 'e', 'f', and so on.

 

You could use 'i' like in the programming textbooks, along 'j', 'k', and so on.

 

Or alternatively you could use 'temp1', 'temp2', 'temp3' at your likeness.

 

  • Like 1
Link to comment
Share on other sites

6 minutes ago, nanochess said:

In IntyBASIC you can make as many variables as required and with any name you want, but obviously every one uses space inside RAM.

 

The internal support subroutines doesn't use any publicly available temporary variable name, so you don't have to worry about crashing the namespace.

 

My personal preference is to use the letter 'c' as a temporary variable, along 'd', 'e', 'f', and so on.

 

You could use 'i' like in the programming textbooks, along 'j', 'k', and so on.

 

Or alternatively you could use 'temp1', 'temp2', 'temp3' at your likeness.

 


My preference is to prefix with “temp” and use names for specific purposes.  So I have “tempX,” “tempY,” “tempDist” (distance), “tempPos” (position), etc.

 

Because some of these kinds of variables are useful in different contexts.  For instance, any subroutine that operates on position coordinates could use those variables for temporary storage.


In my opinion, there is plenty of variable space for most programs, so there is no need to be stingy about them — at least not to start.

 

So, even if you end up creating individual variables for a single use, you shouldn’t have to worry about it unless you feel like you are actually running out.

 

    dZ.

  • Like 1
Link to comment
Share on other sites

51 minutes ago, carlsson said:

I am part of the "i j k l" school when it comes to loop variables and other mostly temporary calculations. My colleagues at work hate my code, in particular the JavaScript part but also PHP.


I use “I,” “j,” “k,” and “l” for loop control variables.  That’s just how it’s done. :)

 

However, everything else gets a real name.

Link to comment
Share on other sites

@nanochess @DZ-Jay Is this correct?

 

Quote

   'movement right to left (1).
   if (rubydirection and 4) <> 0 then goto __Skip_Ruby_R_to_L

   rubyx = rubyx - 1

 

   'skips if edge not reached.
   if rubyx > 16 then goto __Skip_Ruby_L_to_R

 

   'sets new ruby location and direction if player in air and edge reached.
   rubyx = 139 : rubyy = rand(32) + 23 : rubydirection = 1 ' A random number from 23 to 54

   if lyray < 72 && lyrax > 76 then rubyx = 16 : rubydirection = 0

 

   'makes it more random if player on ground.
   if lyray = 72 && rubyx = 139 then temp = rand : if temp > 127 then rubyx = 16 : rubydirection = 0

   goto __Skip_Ruby_L_to_R

 

__Skip_Ruby_R_to_L

 

   'movement left to right (0).
   rubyx = rubyx + 1

 

   'skips if edge not reached.
   if rubyx < 139 then goto __Skip_Ruby_L_to_R

 

   'sets new cube location and direction if player in air and edge reached.
   rubyx = 139 : rubyy = rand(32) + 23 : rubydirection = 1 ' A random number from 23 to 54

   if lyray < 72 && lyrax > 76 then rubyx = 16 : rubydirection = 0

 

   'makes it more random if player is on ground.
   if lyray = 72 && rubyx = 139 then temp = rand : if temp > 127 then rubyx = 16 : rubydirection = 0

__Skip_Ruby_L_to_R

 

Link to comment
Share on other sites

Instead of && you should use AND

 

There should be a colon ending label definitions (I see two label defined without colon)

 

rand cannot be used without an arguments.

 

Other than that it could be compiled.

Link to comment
Share on other sites

12 hours ago, nanochess said:

rand cannot be used without an arguments.

 

😱

 

9 hours ago, nanochess said:

Oh my! Yes, you can use RAND without arguments in IntyBASIC.

 

Forgot my own manual.

 

 

I was just about to post, "OMG! I know something @nanochess doesn't??" <exploding-brain>

 

      -dZ.

  • Haha 1
Link to comment
Share on other sites

1 hour ago, ZippyOasys said:

Incidentally, how do you use fixed points on IntyBasic? I kinda want my enemy MOBs to move in a fractional speed.


You just reserve a set of bits in a word for the fractional part.  For example, using a 16-bit variable to represent a fractional position, you could use 8-bits for the integer and 8-bits for the fractional part (Q8.8).  This provides for 1/256th precision.


The precision is always 1/2n where n is the number of bits reserved for the fraction.

 

(In our example of a Q8.8 fixed point number, the fraction is always in terms of 1/256th.  This is because there are 8 bits of precision (28 = 256), and you are ultimately dealing with binary numbers.  For example, 0.5 is actually $0080, which is 1/2 of 256.)

 

In this scenario, 1.00 is represented by $1OO or (256 in decimal); 1.50 would be $180, and so forth.

 

You can add and subtract fixed-point values normally, as long as they are all at the same scale — that is, the number of binary bits reserved for the fraction need to be the same for all numbers in the operation.

 

You can scale any integer or fractional value to a different fractional precision by multiplying by 2 (more precision) or dividing by 2 (less precision).

 

You can scale back the fixed point value to its integer portion by dividing by 2n where n is the number of bits of precision.  In the example above of Q8.8, you divide the value by 28 or 256.

 

   dZ.

Link to comment
Share on other sites

10 hours ago, ZippyOasys said:

@DZ-Jay So Enemyx = Enemyx - 0.80 becomes Enemyx = Enemyx - $0080 (0.5). Is this correct?


First, you need to use 16-bit variables, which are prefixed by the "#" symbol.  Second, the decimal fraction needs to be scaled by 1/256, so 0.80 (decimal) becomes $00CD (hexadecimal).  (The fraction is multiplied by 256.)

 

So it should be:

#Enemyx = #Enemyx - $00CD


Using Hexadecimal is just for convenience, since you can see the two bytes for the integer and he fraction separately ($00CD = 00.205).


Remember that the integer is in the upper byte, so you need to divide by 256 in order to get it:

' Get the integer position
X = (#Enemyx / 256)

 

     dZ.

 

 

P.S. Corrected the 16-bit variable prefix symbol from "&" to "#."  Thanks to @carlsson for pointing it out.  (Sorry!)

Edited by DZ-Jay
Fixed 16-bit variable prefix symbol
Link to comment
Share on other sites

IntyBASIC uses # for 16-bit variables. Doesn't the fixed point mode already handle fractions? From the manual:

 

#A = 1.5 (translated as $8001, of which the high byte is the fraction)

#A = #A+.#B

 

I've never used it, so I don't know how it works if you mix 16-bit fixed point and regular 8-bit variables.

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