English Amiga Board Want to learn Blitz, but I have a problem.
 User Name Remember Me? Password
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 08 January 2012, 17:07 #41 diablothe2nd Registered User   Join Date: Dec 2011 Location: Northampton, UK Age: 35 Posts: 1,232 my algrebra sucks. I'm trying to create a variable that counts from 255 down, in 1 step increments. n=n-1 seems to take care of the negative step... but its getting the starting number of 255 in there somewhere that's screwing with my head closest i've got is: x=255 n=n-1+x which is obviously wrong. I know there's a simple answer but I've been thinking about this too hard i think and got my head stuck in it's own loop
 AdSense
 08 January 2012, 17:10 #42 diablothe2nd Registered User   Join Date: Dec 2011 Location: Northampton, UK Age: 35 Posts: 1,232 n=n-1+255? ugh maybe i'm doing this wrong and simply need to make N a number that goes from 255-0 in another way. multiple for and next loops dont seem to all work at once which i why i'm declaring them as variables first. Last edited by prowler; 08 January 2012 at 22:48. Reason: Back-to-back posts merged.
 08 January 2012, 17:43 #43 diablothe2nd Registered User   Join Date: Dec 2011 Location: Northampton, UK Age: 35 Posts: 1,232 here's the code, perhaps it'll explain more: Code: ```y=255-(n=n+1) For z=255 to 0 Step -1:Line 0,y,320,y,z,1:Next``` which *should* simply draw a gradient of white to black from bottom to top.
08 January 2012, 22:27   #44
P-J
Grumpy veteran

Join Date: Mar 2001
Location: Moorpark, California
Age: 38
Posts: 1,146
Quote:
 Originally Posted by diablothe2nd here's the code, perhaps it'll explain more: Code: ```y=255-(n=n+1) For z=255 to 0 Step -1:Line 0,y,320,y,z,1:Next``` which *should* simply draw a gradient of white to black from bottom to top.
This makes no sense dude. You want to draw from Y-line 255 to Y-Line 0 one by one, have the colour value also go from 255 to 0 as you come back up?

Why not just :

Quote:
 For y=255 to 0 Step -1:Line 0,y,320,y,y,1:Next
Also, you said earlier that multiple FOR/NEXT loops wouldn't do what you wanted. Were you using nested loops?

08 January 2012, 22:31   #45
diablothe2nd
Registered User

Join Date: Dec 2011
Location: Northampton, UK
Age: 35
Posts: 1,232
Quote:
 Originally Posted by P-J Why not just : Code: `For y=255 to 0 Step -1:Line 0,y,320,y,y,1:Next` Also, you said earlier that multiple FOR/NEXT loops wouldn't do what you wanted. Were you using nested loops?
Gah! so simple to me now. i was totally overthinking it and got myself in a tizzy.

thanks

RE:loops, no i think i was simply misunderstanding how they work.

say though that the Z and Y values were opposite. one climbing to 255, one reducing. how would i go about doing that?

much obliged!

Last edited by diablothe2nd; 08 January 2012 at 22:35. Reason: edited many times cos i'm tired and keep messing up :P

08 January 2012, 22:35   #46
P-J
Grumpy veteran

Join Date: Mar 2001
Location: Moorpark, California
Age: 38
Posts: 1,146
Quote:
 Originally Posted by diablothe2nd say though that the Z and Y values were opposite. one climbing to 255, one reducing. how would i go about doing that?
Plain version

Code:
`For y=255 to 0 Step -1:Line 0,y,320,y,(255 - y),1:Next`
Better version for learning

Code:
```for y=255 to 0 step -1
z = (255 - y)   // So if y = 255, z = 0. If y = 254, z = 1 (etc...)
line 0, y, 320, y, z, 1
next```
A good way to do this sort of stuff is with a pen and paper. Write down the values you want side by side, and then try and work out a formula that links them. In this sort of case it's not necessary, but as you do game programming you could come up against some real sticky situations that need a lot of maths. That's when I turn to the trusty pen and paper and just draw it out.

In this case you could also use some kind of 8-bit NOT if your language supports in. NOT(255) would be 0, NOT (254) would be 1 and so on. But it's worth getting an understanding of binary to understand how that works. Not really worth it if you're coding in basic since that's all taken care of with built-in stuff.

Hope this helps.

Last edited by P-J; 08 January 2012 at 22:44.

 08 January 2012, 22:40 #47 diablothe2nd Registered User   Join Date: Dec 2011 Location: Northampton, UK Age: 35 Posts: 1,232 effin' AWESOME! just what the doctor ordered algebra was never my strong point. and i've never come across For and Next functions before so wasn't sure what i could get away with.
08 January 2012, 22:54   #48
P-J
Grumpy veteran

Join Date: Mar 2001
Location: Moorpark, California
Age: 38
Posts: 1,146
Quote:
 Originally Posted by diablothe2nd algebra was never my strong point.
Me neither. When I left school and spent 23 hours a day coding on the Amiga (and then PC), I learnt more algebra in a few days than I was ever able to learn at school.

Have you used debuggers before? I think Blitz has one, and possibly a better replacement somewhere. It's a useful learning tool because you can (for example) add a watch on a variable, step through your code, and then see how that variable is affected by each operation. It's great to get into the habit of using one, especially if you plan to progress to coding in assembly.

08 January 2012, 22:55   #49
diablothe2nd
Registered User

Join Date: Dec 2011
Location: Northampton, UK
Age: 35
Posts: 1,232
just to add to your edit

Quote:
 in this case you could also use some kind of 8-bit NOT if your language supports in. NOT(255) would be 0, NOT (254) would be 1 and so on. But it's worth getting an understanding of binary to understand how that works. Not really worth it if you're coding in basic since that's all taken care of with built-in stuff.
ironically i'm quite knowledgable in both binary and hex. The difficulty for me though is i've never done any programming more advanced than editing configs, so dont know what function to choose, and more specifically when it should be used.

the pdf of functions is helping though. I guess it's like CAD, or any graphical program that i'm completely fluent in. There are many ways of doing it, but figuring out the most efficient way is only gained from experience. If i wanted to draw say a hexagon on screen i wouldn't know whether or not to draw all 6 lines using 6 line parameters... or use 1 and somehow copy and manipulate it! in CAD it'd be 2 key presses, 1 click and typing a single dimension... total time taken, 3 seconds :P

its so frustrating for me, cos i've got a near photographic/videographic image my head of everything i want the end user to see and do... from launching the game to finishing/completing it. putting that down into images is a piece of piss for me. coding it though.... phew! I've noticed you programmers start out with a vague idea and just go with the flow. I think my line of thinking of "this is what it will be", even though i'm considering limitations of hardware, is my problem. i simply have no knowledge of the tools infront of me to back trace.

Last edited by diablothe2nd; 08 January 2012 at 23:01.

09 January 2012, 04:25   #50
Thorham
Computer Nerd

Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 41
Posts: 2,977
Going from dark to light:
Code:
```for y=0 to 255 step 1
line 0, y, 320, y, y, 1
next```
Going from light to dark:
Code:
```z=255
for y=0 to 255 step 1
line 0, y, 320, y, z, 1
z=z-1
next```
Note that 'step 1' may be removable (most basic dialects default to 'step 1' for 'for next' loops).
Quote:
 Originally Posted by diablothe2nd I've noticed you programmers start out with a vague idea and just go with the flow.
Not really, because that is the worst way to write programs; you really have to think it out properly, or you'll end up with a mess. It's similar to the good (bad!) old: 'Type first, think later' way of programming.

Last edited by Thorham; 09 January 2012 at 04:52.

09 January 2012, 09:13   #51
pmc
rebooting...

Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
 Originally Posted by Thorham Not really, because that is the worst way to write programs; you really have to think it out properly, or you'll end up with a mess. It's similar to the good (bad!) old: 'Type first, think later' way of programming.
Agree.

Think first, code second!

This gets quicker as you get more experienced as you start getting to the stage where you kind of know how to go about coding something as you're coding, or at least a few split seconds before you write the actual code. That's how it feels to me at least.

But if something's larger, more unfamiliar or new the first thing I do is spend time coding things "in my head" first.

09 January 2012, 10:12   #52
Graham Humphrey
Moderator

Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 31
Posts: 11,021
Quote:
 Originally Posted by diablothe2nd my first hurdle seems to be colour codes. the circle command syntax has only one spot on the end for a colour code and i can't find the correct syntax for a non grey colour. i've tried using RGB hex values, both with and without a hash (#) but it's not having it.
'Colour' in this case has to be a colour number from the palette you're using. If you're using 256 colours for example you have to pick a number from 0 to 255 and the circle will be drawn using that colour register.

 09 January 2012, 12:36 #53 diablothe2nd Registered User   Join Date: Dec 2011 Location: Northampton, UK Age: 35 Posts: 1,232 thanks for clearing that one up graham
 AdSense

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

 Similar Threads Thread Thread Starter Forum Replies Last Post mancity support.Apps 26 21 May 2012 06:14 Adropac2 request.Other 20 20 August 2008 07:30 Graham Humphrey Coders. General 10 09 August 2008 09:24 BippyM Coders. General 80 01 April 2007 19:25 MethodGit Retrogaming General Discussion 7 07 December 2001 13:03

 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     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     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 Off Topic     OT - General     OT - Technical     OT - Entertainment     OT - Sports     OT - Gaming

All times are GMT +2. The time now is 20:38.

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

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.54160 seconds with 14 queries