English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 08 January 2012, 00:39   #21
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
woohoo! sussed it :D

I wanted to draw a gradient from a corner (to test my muscle on operators with vectors)

Quote:
BitMap 0,320,256,8

For i=0 To 255:AGAPalRGB 0,i,i,i,i:Next

InitCopList 0,44,256,$13008,8,256,0

BLITZ

CreateDisplay 0
DisplayBitMap 0,0:DisplayPalette 0,0

;While ;key NOT pressed

;draw corner gradient
For x=0 To 255 Step 1: Line 0,0,x,255,x,1:Next
For y=255 To 0 Step -1: Line 0,0,255,y,y,1:Next

;Wend

;draw sphere (from previous code example)
;For i=255 To 0 Step -1:Circlef 160,128,i/4,i :Next

MouseWait

End
simple things please simple minds :D
Attached Thumbnails
Click image for larger version

Name:	gradient.png
Views:	214
Size:	17.2 KB
ID:	30316  
diablothe2nd is offline  
Old 08 January 2012, 00:45   #22
Djay
95th User
 
Djay's Avatar
 
Join Date: May 2001
Location: Brighton/UK
Age: 48
Posts: 3,120
Quote:
Originally Posted by diablothe2nd View Post
when it gets caught in a loop i'm having to reset the system and reload Blitz, and the code. would be nice to just break the routine using a while loop without having to reset the whole system.
and so, stick in a line of code which will detect if a certain key is pressed during the loop, in which it will exit the program

once you have discovered what it is you'll probably never forget it

i would imagine that the is crtl-break method of exiting to the editor, but its handy to actually have it in your code

sometime i have to learn a command exists though a manual...
Djay is offline  
Old 08 January 2012, 00:48   #23
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Quote:
Originally Posted by Djay View Post
and so, stick in a line of code which will detect if a certain key is pressed during the loop, in which it will exit the program
hence my question of whats the command to detect a keypress?

which i'll invert into while key is NOT pressed, continue.

wouldn't mind someone offering up their blitz source code from some copper tricks actually - if anyones got any?

Last edited by Graham Humphrey; 08 January 2012 at 00:59. Reason: Back-to-back posts merged
diablothe2nd is offline  
Old 08 January 2012, 01:01   #24
Djay
95th User
 
Djay's Avatar
 
Join Date: May 2001
Location: Brighton/UK
Age: 48
Posts: 3,120
this might work..
Code:
While Not KeyHit(KEY_ESCAPE)
	If KeyDown(KEY_SPACE) Exit
Wend
Djay is offline  
Old 08 January 2012, 01:04   #25
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Quote:
Originally Posted by Djay View Post
this might work..
Code:
While Not KeyHit(KEY_ESCAPE)
    If KeyDown(KEY_SPACE) Exit
Wend
almost. it complains the array is not DIM'd

can i simply do:

Quote:

If KeyDown(KEY_SPACE) Exit

[code]

endif
edit, nope still complains of not DIM'd

Last edited by Graham Humphrey; 08 January 2012 at 01:30. Reason: Back-to-back posts merged
diablothe2nd is offline  
Old 08 January 2012, 01:14   #26
Djay
95th User
 
Djay's Avatar
 
Join Date: May 2001
Location: Brighton/UK
Age: 48
Posts: 3,120
i think its
--

Code:
If KeyHit(1)
	End
End If
--
(1)=ESC i think!
Djay is offline  
Old 08 January 2012, 01:14   #27
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Quote:
Originally Posted by Djay View Post
i think its
--

Code:
If KeyHit(1)
    End
End If
--
(1)=ESC i think!

according to this: http://whdload.de/docs/en/rawkey.html

it's 45. i'll try it!

nah still not having it and pointing me to the keypress/hit line.

pressing the help hey over keyhit and keydown it doesn't give me any syntax help. it also doesn't turn pink like when i put in other functions... so i'm guessing it's not a valid function?

argh i need a glossary of functions

Last edited by Graham Humphrey; 08 January 2012 at 01:31. Reason: Back-to-back posts merged
diablothe2nd is offline  
Old 08 January 2012, 01:19   #28
Djay
95th User
 
Djay's Avatar
 
Join Date: May 2001
Location: Brighton/UK
Age: 48
Posts: 3,120
Quote:
Originally Posted by diablothe2nd View Post
according to this: http://whdload.de/docs/en/rawkey.html

it's 45. i'll try it!
i think thats something for setting a exit (or action) for WHDLoad Games/Software... not for blitz

i think this is for blitz

Code:
Const KEY_ESCAPE = 1
Const KEY_1 = 2
Const KEY_2 = 3
Const KEY_3 = 4
Const KEY_4 = 5
Const KEY_5 = 6
Const KEY_6 = 7
Const KEY_7 = 8
Const KEY_8 = 9
Const KEY_9 = 10
Const KEY_0 = 11
Const KEY_MINUS = 12
Const KEY_EQUALS = 13
Const KEY_BACKSPACE = 14
Const KEY_TAB = 15
Const KEY_Q = 16
Const KEY_W = 17
Const KEY_E = 18
Const KEY_R = 19
Const KEY_T = 20
Const KEY_Y = 21
Const KEY_U = 22
Const KEY_I = 23
Const KEY_O = 24
Const KEY_P = 25
Const KEY_LEFT_BRACKET = 26
Const KEY_RIGHT_BRACKET = 27
Const KEY_RETURN = 28
Const KEY_LEFT_CONTROL = 29
Const KEY_A = 30
Const KEY_S = 31
Const KEY_D = 32
Const KEY_F = 33
Const KEY_G = 34
Const KEY_H = 35
Const KEY_J = 36
Const KEY_K = 37
Const KEY_L = 38
Const KEY_SEMICOLON = 39
Const KEY_APOSTROPHE = 40
Const KEY_GRAVE = 41
Const KEY_LEFT_SHIFT = 42
Const KEY_BACKSLASH = 43
Const KEY_Z = 44
Const KEY_X = 45
Const KEY_C = 46
Const KEY_V = 47
Const KEY_B = 48
Const KEY_N = 49
Const KEY_M = 50
Const KEY_COMMA = 51
Const KEY_PERIOD = 52
Const KEY_SLASH = 53
Const KEY_RIGHT_SHIFT = 54
Const KEY_MULTIPLY = 55
Const KEY_LEFT_ALT = 56
Const KEY_SPACE = 57
Const KEY_CAPITAL = 58
Const KEY_F1 = 59
Const KEY_F2 = 60
Const KEY_F3 = 61
Const KEY_F4 = 62
Const KEY_F5 = 63
Const KEY_F6 = 64
Const KEY_F7 = 65
Const KEY_F8 = 66
Const KEY_F9 = 67
Const KEY_F10 = 68
Const KEY_NUMLOCK = 69
Const KEY_SCROLLLOCK = 70
Const KEY_NUMPAD7 = 71
Const KEY_NUMPAD8 = 72
Const KEY_NUMPAD9 = 73
Const KEY_SUBTRACT = 74
Const KEY_NUMPAD4 = 75
Const KEY_NUMPAD5 = 76
Const KEY_NUMPAD6 = 77
Const KEY_ADD = 78
Const KEY_NUMPAD1 = 79
Const KEY_NUMPAD2 = 80
Const KEY_NUMPAD3 = 81
Const KEY_NUMPAD0 = 82
Const KEY_DECIMAL = 83
Const KEY_OEM_102 = 86
Const KEY_F11 = 87
Const KEY_F12 = 88
Const KEY_F13 = 100
Const KEY_F14 = 101
Const KEY_F15 = 102
Const KEY_KANA = 112
Const KEY_ABNT_C1 = 115
Const KEY_CONVERT = 121
Const KEY_NOCONVERT = 123
Const KEY_YEN = 125
Const KEY_ABNT_C2 = 126
Const KEY_NUMPAD_EQUALS = 141
Const KEY_PREVTRACK = 144
Const KEY_AT = 145
Const KEY_COLON = 146
Const KEY_UNDERLINE = 147
Const KEY_KANJI = 148
Const KEY_STOP = 149
Const KEY_AX = 150
Const KEY_UNLABELED = 151
Const KEY_NEXTTRACK = 153
Const KEY_ENTER = 156
Const KEY_RIGHT_CONTROL = 157
Const KEY_MUTE = 160
Const KEY_CALCULATOR = 161
Const KEY_PLAY_PAUSE = 162
Const KEY_MEDIASTOP = 164
Const KEY_VOLUME_DOWN = 174
Const KEY_VOLUME_UP = 176
Const KEY_WEB_HOME = 178
Const KEY_NUMPAD_COMMA = 179
Const KEY_DIVIDE = 181
Const KEY_SYSREQ = 183
Const KEY_RIGHT_ALT = 184
Const KEY_PAUSE = 197
Const KEY_HOME = 199
Const KEY_UP = 200
Const KEY_PAGEUP = 201
Const KEY_LEFT = 203
Const KEY_RIGHT = 205
Const KEY_END = 207
Const KEY_DOWN = 208
Const KEY_NEXT = 209
Const KEY_INSERT = 210
Const KEY_DELETE = 211
Const KEY_LEFTWINDOWS = 219
Const KEY_RIGHTWINDOWS = 220
Const KEY_APPS = 221
Const KEY_POWER = 222
Const KEY_SLEEP = 223
Const KEY_WAKE = 227
Const KEY_WEBSEARCH = 229
Const KEY_WEBFAVORITES = 230
Const KEY_WEBREFRESH = 231
Const KEY_WEBSTOP = 232
Const KEY_WEBFORWARD = 233
Const KEY_WEBBACK = 234
Const KEY_MYCOMPUTER = 235
Const KEY_MAIL = 236
Const KEY_MEDIASELECT = 237
Djay is offline  
Old 08 January 2012, 01:22   #29
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Quote:
Originally Posted by Djay View Post
i think thats something for setting a exit (or action) for WHDLoad Games/Software... not for blitz

i think this is for blitz

Code:
snipped
i'm saving that to my HD

1 still dont work for the reason above your post (sorry for double post)

EDIT - also, there are alot of key descriptions on that list that dont apply to any amiga keyboard i know of?? where'd you find that?
diablothe2nd is offline  
Old 08 January 2012, 01:29   #30
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
Djay - the WHDLoad link to the rawkey codes are correct as they're Amiga keycodes so Escape is 45.

Here's a link to a PDF Blitz manual that should contain everything you need - http://math.ut.ee/~isotamm/PKeeled/T...Manual-ENG.pdf

The command for checking keypresses is RawStatus. However before you use that you must use the command 'BlitzKeys On' if you're in Blitz mode otherwise it won't work.

So if you want to check for a press of Escape, you'd use 'While NOT RawStatus($45)'.
Graham Humphrey is offline  
Old 08 January 2012, 01:31   #31
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
fantastic Graham!

do i need to call Blitzkeys before or after entering blitz mode? i'm assuming before as after pretty much kills most DOS access?
diablothe2nd is offline  
Old 08 January 2012, 01:31   #32
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
No, you call BlitzKeys after entering Blitz mode as it's a Blitz mode command
Graham Humphrey is offline  
Old 08 January 2012, 01:34   #33
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
right-you-are boss
diablothe2nd is offline  
Old 08 January 2012, 01:35   #34
Djay
95th User
 
Djay's Avatar
 
Join Date: May 2001
Location: Brighton/UK
Age: 48
Posts: 3,120
i played around with Blitz for PC sometime ago, it was something i had saved...

i think some of instructions work on both platforms...

---
glad to see Graham solved it...
Djay is offline  
Old 08 January 2012, 01:43   #35
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Sorry Graham I need your expertise again.

It's now stuck in a loop and keeps drawing the line gradient now

Code:
BitMap 0,320,256,8

For i=0 To 255:AGAPalRGB 0,i,i,i,i:Next

InitCopList 0,44,256,$13008,8,256,0

BLITZ

CreateDisplay 0
DisplayBitMap 0,0:DisplayPalette 0,0

BlitzKeys On

While NOT RawStatus($45)

;my (failed) attempt at a variable list
; x1=0
; x2=320 To 0 Step -1
; y1=0
; y2=0 To 256 Step 1


For x=0 To 255 Step 1: Line 0,0,x,255,x,1:Next
For y=255 To 0 Step -1: Line 0,0,255,y,y,1:Next

;wanted to use above variables here for another experiement:
;For z=255 To 0 Step -1: Line x1,y1,x2,y2,z,1

Wend

;gradient circle
;For i=255 To 0 Step -1:Circlef 160,128,i/4,i :Next

MouseWait

End
diablothe2nd is offline  
Old 08 January 2012, 12:41   #36
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
So pressing Escape doesn't work? I usually use a Repeat...Until loop so I just replaced it with While...Wend in one of my programs and it worked fine.

Maybe try including a 'VWait' command at the start of the loop and see if that makes a difference. Otherwise (I know it's not a solution) but if the debugger is enabled I think Ctrl-C will interrupt the program.
Graham Humphrey is offline  
Old 08 January 2012, 12:53   #37
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
correct, escape has no effect.

i'll try vwait


EDIT - adding Vwait after the while rawstatus didn't work either.

could this have anything to do with me running in winuae?

Last edited by diablothe2nd; 08 January 2012 at 13:02.
diablothe2nd is offline  
Old 08 January 2012, 13:22   #38
Graham Humphrey
Moderator
 
Graham Humphrey's Avatar
 
Join Date: Jul 2004
Location: Norwich, Norfolk, UK
Age: 37
Posts: 11,167
I just copied your code over to my Amiga and ran it and I had the exact same issue (Ctrl-C didn't even work) so it's certainly not a WinUAE issue.
Graham Humphrey is offline  
Old 08 January 2012, 14:24   #39
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
no worries... i've ditched playing and am now working on my game idea (Amigeddon).

I'm drawing a solid circle, and a circle outline around it. I want to work on collision detection. the solid circle is white, and i want the ring around it to be blue so i can tell bob to collide with the outer ring only if the fire button is pressed, if fire not pressed, collide with solid circle afterwards.

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. would i be correct to assume that drawing such graphics in this way is too limiting and i should simply use an image in the form of a bob?

click image to enlarge as it lacks detail in thumbnail mode
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	200
Size:	6.5 KB
ID:	30317  

Last edited by diablothe2nd; 08 January 2012 at 14:27. Reason: Added image explaining my issues
diablothe2nd is offline  
Old 08 January 2012, 16:08   #40
diablothe2nd
Registered User
 
Join Date: Dec 2011
Location: Northamptonshire, UK
Age: 41
Posts: 1,236
Looking through further examples, this seems to be the method for a mouseclick to end the loop without needing BlitzKeys ON


Quote:
While Joyb(0)=0
Vwait

[code]

Wend
when tested with my gradient code, it works when you hold the mouse button down just as it's finishing drawing
diablothe2nd is offline  
 


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

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 Jump


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

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09814 seconds with 16 queries