08 January 2012, 17:07 | #41 |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
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 |
08 January 2012, 17:10 | #42 |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
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 |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
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 |
08 January 2012, 22:27 | #44 | ||
Registered User
Join Date: Mar 2001
Location: Moorpark, California
Age: 44
Posts: 1,153
|
Quote:
Why not just : Quote:
|
||
08 January 2012, 22:31 | #45 | |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
Quote:
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 | |
Registered User
Join Date: Mar 2001
Location: Moorpark, California
Age: 44
Posts: 1,153
|
Quote:
Code:
For y=255 to 0 Step -1:Line 0,y,320,y,(255 - y),1:Next 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 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 |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
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 |
Registered User
Join Date: Mar 2001
Location: Moorpark, California
Age: 44
Posts: 1,153
|
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 | |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
just to add to your edit
Quote:
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 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
Going from dark to light:
Code:
for y=0 to 255 step 1 line 0, y, 320, y, y, 1 next Code:
z=255 for y=0 to 255 step 1 line 0, y, 320, y, z, 1 z=z-1 next 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 | |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
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 | |
Moderator
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
|
Quote:
|
|
09 January 2012, 12:36 | #53 |
Registered User
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
|
thanks for clearing that one up graham
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I want to learn about Workbench | mancity | support.Apps | 26 | 21 May 2012 06:14 |
Wanting to learn Blitz Basic on real Amiga | Adropac2 | request.Other | 20 | 20 August 2008 07:30 |
Blitz Basic 2.1 problem with reading a CD32 joypad | Graham Humphrey | Coders. General | 10 | 09 August 2008 09:24 |
How did you learn to program | BippyM | Coders. General | 80 | 01 April 2007 19:25 |
A little lesson to learn about Pong | MethodGit | Retrogaming General Discussion | 7 | 07 December 2001 13:03 |
|
|