English Amiga Board Blitz Basic 2 basics
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 27 March 2017, 02:38 #41 Jackoland Registered User   Join Date: Jun 2014 Location: Leeds Posts: 167 The most basic of questions! How do I generate on positive random numbers I'm doing this at the moment Rent1=int (rnd(80-150)) But this generates numbers bigger than the range set and negative numbers too. Cheers I have been using blitz for about a day. And have the programming knowledge of a nat! Rich
 27 March 2017, 07:31 #42 tolkien AmigaMan   Join Date: Oct 2012 Location: Castro Urdiales/Spain Posts: 511 Rent1 = rnd(70)+80 Rnd(70) cos the difference between 80 and 150. Rnd will generate numbers between 0 and 70 so sum 80 for the offset.
27 March 2017, 07:37   #43
MickGyver
Registered User

Join Date: Oct 2008
Location: Finland
Posts: 407
Quote:
 Originally Posted by Jackoland The most basic of questions! How do I generate on positive random numbers I'm doing this at the moment Rent1=int (rnd(80-150)) But this generates numbers bigger than the range set and negative numbers too. Cheers I have been using blitz for about a day. And have the programming knowledge of a nat! Rich
Here are two examples:

Generate a number between 0 and 150:
Rent1.w = Rnd(150)

Generate a number between 80 and 150
Rent1.w = Rnd(70)+80

Keep at it, Blitz Basic is fun!

EDIT: Tolkien answered this while I was writing...

27 March 2017, 09:44   #44
Daedalus
Registered User

Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,011
Quote:
 Originally Posted by Jackoland I'm doing this at the moment Rent1=int (rnd(80-150))
The others have already answered this, I hope it makes sense. I'd just like to add that you don't need the Int() function in Blitz - the Rnd() function automatically returns an integer when the range is greater than 1. Some other BASICs do need it, but it looks neater without it

 27 March 2017, 10:54 #45 Coagulus Gets there in the end...   Join Date: Sep 2005 Location: Wales Posts: 637 To clarify, in Blitz, 80-150 means 80 MINUS 150 not 80 TO 150 like you would write in reality.
 27 March 2017, 11:57 #46 Jackoland Registered User   Join Date: Jun 2014 Location: Leeds Posts: 167 That's great folks! Thanks for the help. I'm really glad of this thread. I don't feel bad asking dumb questions. I'm having a go at a basic shop simulator game. Things like buying, rent, profits and reputation variables. If I can get a system running, I then want to add in a graphical interface! Slowly learning, expect more questions! Cheers rich
 27 March 2017, 12:14 #47 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,011 The only dumb questions are the ones you don't ask Okay, maybe there are some dumb questions, but feel free to ask for help here any time, there are plenty of people around who should be able to help. The built-in Blitz help is pretty good, and the Blitz section of AmigaCoding.com has a lot of useful reference material too.
 29 March 2017, 08:27 #49 tolkien AmigaMan   Join Date: Oct 2012 Location: Castro Urdiales/Spain Posts: 511 I like this thread as Im learning blitz basic but I think we should write each question in differents threads to can search it more easy in the future.
29 March 2017, 09:48   #50
MickGyver
Registered User

Join Date: Oct 2008
Location: Finland
Posts: 407
Quote:
 Originally Posted by Jackoland The help I need now is I need lots of products to choose from, it will have a name, cost, year and also the amount it will increase the shops reputation. Would I be best using an array to store these variables?
You should make a NewType (similar to a C struct) that includes the data for the products. Then you can create an array of that NewType. Like this:

Code:
```; Create a NewType for products
NEWTYPE .Product
name\$
cost.w
year.w
End NEWTYPE

; Create an array named "Products" containing 200 ".Product" NewType objects (actually 201)
Dim Products.Product(200)```
Quote:
 Originally Posted by tolkien I like this thread as Im learning blitz basic but I think we should write each question in differents threads to can search it more easy in the future.
I was thinking the same thing yesterday, it's probably for the best to have separate threads for separate questions.

Last edited by MickGyver; 29 March 2017 at 11:10.

29 March 2017, 09:57   #51
twiggy

Join Date: Nov 2008
Location: Devon, U.K.
Age: 30
Posts: 390
Quote:
 Originally Posted by tolkien I like this thread as Im learning blitz basic but I think we should write each question in differents threads to can search it more easy in the future.
Unless we rename this thread "Blitz Basic questions you've always been too embarrassed to ask"

 29 March 2017, 16:12 #52 Jackoland Registered User   Join Date: Jun 2014 Location: Leeds Posts: 167 Where am I best declaring the new type? At the beginning in a setup variables procedure? Cheers
 29 March 2017, 16:46 #53 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,011 You're best off declaring it at the start of your code - it must be before you intend to use it for the first time. I normally have an area near the start of my code where I declare all the arrays, variables, constants and default values I use later on. If you intend to use it in more than one area of your code, you shouldn't declare it in a procedure, as then it would only be local to that procedure.
 29 March 2017, 23:17 #54 idrougge Registered User   Join Date: Sep 2007 Location: Stockholm Posts: 3,793 I like to declare them in a separate file and XINCLUDE it at the top of the main file. It makes the main file less cluttered.
 29 March 2017, 23:44 #55 tolkien AmigaMan   Join Date: Oct 2012 Location: Castro Urdiales/Spain Posts: 511 Nice idea. I'm trying to do all my code more modular.
 27 April 2017, 08:17 #56 Havie Registered User   Join Date: Mar 2012 Location: UK Posts: 383 Can someone help me with palettes please! I am using the new Display library commands and Use Palette doesn't work - I keep getting an error that there is no object. So - I have realised that I can't use old commands with the new display list but I have no idea how to get a palette from a shape. I have tried loading with shape with the optional palette command at the end but whatever I do I can't seem to change to this palette. Help!!!
27 April 2017, 09:51   #57
MickGyver
Registered User

Join Date: Oct 2008
Location: Finland
Posts: 407
Quote:
 Originally Posted by Havie Can someone help me with palettes please! I am using the new Display library commands and Use Palette doesn't work - I keep getting an error that there is no object. So - I have realised that I can't use old commands with the new display list but I have no idea how to get a palette from a shape. I have tried loading with shape with the optional palette command at the end but whatever I do I can't seem to change to this palette. Help!!!
Hmm, I haven't used BB2 very much but what has been working for me is to load the palette from the image (containing shapes) with

Code:
`LoadPalette 0,"image.iff"`
and then after creating the copperlist use DisplayPalette instead of Use Palette

Code:
```; DisplayPalette #coplist, #palette
DisplayPalette 0,0```

 27 April 2017, 22:54 #58 Havie Registered User   Join Date: Mar 2012 Location: UK Posts: 383 Thanks - will have a go and let you know!
 28 April 2017, 22:32 #59 Daedalus Registered User   Join Date: Jun 2009 Location: Dublin, then Glasgow Posts: 4,011 That should also work with a palette loaded optionally with the LoadShape command. The Use Palette command is only for screens and slices from what I remember, and was replaced with ShowPalette anyway, which would explain why it doesn't work. DisplayPalette is the equivalent for the Display library so that should work fine.
 28 April 2017, 23:16 #60 Havie Registered User   Join Date: Mar 2012 Location: UK Posts: 383 Still struggling - I think I need to sort out the number of bitplanes in the original shapes! Just trying to have black and white and thought I could do this with 1 bit plane. Then think I need 2 bit planes if I want to convert shape to sprite. The thinking that maybe I haven't set up screen properly. I think I will grab some code from a working game and start again...

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post saimon69 Coders. Blitz Basic 104 29 November 2016 20:45 Retro1234 Coders. Blitz Basic 9 18 February 2016 17:54 Havie Coders. Blitz Basic 30 08 September 2013 09:15 jobro request.Apps 12 28 November 2005 18:15 LaundroMat Retrogaming General Discussion 5 24 July 2001 08:10

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 05:57.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top