Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]   Go Down

Author Topic: New to Amos Pro, looking to start *simple* programming in A.P  (Read 8647 times)

0 Members and 1 Guest are viewing this topic.

LordNipple

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 12
    • Wayne Ashworth Art.
Re: New to Amos Pro, looking to start *simple* programming in A.P
« Reply #15 on: June 09, 2015, 10:03:11 AM »

Welcome m'lord.  Arrays confused me also in my early AMOS programming days.  Ultimately I did come to understand and even love them.

An array is simply a way to store many related variables in one single place.  For instance, say I have a game with 4 players and each one has an energy level 0-100.  I can create an array to store all their energy levels together for easy access:

Dim ENERGY(4)

At the start of the game I then set all 4 player's energy to 100, we start counting with 0:

ENERGY(0)=100
ENERGY(1)=100
ENERGY(2)=100
ENERGY(3)=100

Now, during the game I can add or subtract energy using normal arithmetic, I just use the array name and the player number:

Rem This subtracts 15 energy points from player 0
ENERGY(0) = ENERGY(0) - 15
Print ENERGY(0)

So that's pretty much it.

You can also create arrays that act like grids.  These are called 2 dimensional arrays and can be useful for tracking pieces on a board game like chess or battleship.  You create one of these arrays by using Dim with more than one number in the parentheses:

Rem A 2D array
Dim CHESSBOARD(8,8)

Then you can access the value (that might indicate which pieces is at a given point on the board) like so:

Rem Find the piece located at row 4, column 7.
PIECE = CHESSBOARD(4,7)

Remember to always start counting row and columns at 0.

You can have as many dimensions in an array as you want, so a 3D array would be like a cube:

Dim CUBE(10,10,10)

Higher dimensions can also be used, but can be difficult to visualize.  Anyway, I hope this helps a little.  If not, let me know and I'll try to explain it differently.

And again, welcome!

Thankyou for the welcome and the explanation!
I have to say, I understand it a little better now.

I managed to bag myself a boxed copy of Amos Pro off Ebay, complete with manual recently as I would like to code on an actual Amiga. I recently befriended the guy who made Poker Mania and he has offered me help also (where he can) which is great.
I think anything I make will be very basic until I grasp the syntax etc.


Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: New to Amos Pro, looking to start *simple* programming in A.P
« Reply #16 on: June 09, 2015, 11:09:41 AM »

Depending on the version of AmosPro, you may need to download some updates from here to get it working right.  My original disks were version 1.12 so when the compiler became freeware, installing it to my hard drive updated it to 2.0.
Logged

LordNipple

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 12
    • Wayne Ashworth Art.
Re: New to Amos Pro, looking to start *simple* programming in A.P
« Reply #17 on: June 09, 2015, 11:50:35 AM »

Depending on the version of AmosPro, you may need to download some updates from here to get it working right.  My original disks were version 1.12 so when the compiler became freeware, installing it to my hard drive updated it to 2.0.

I downloaded a .zip of a p.c installable version of amospro from E.A.B, with all updates etc included. I suspect this would be my best option as it has the various editors installed also.
:)
Logged
Pages: 1 [2]   Go Up
 

TinyPortal 2.2.2 © 2005-2022