Well I changed the code with the suggestion from Preben which when I looked you was right as I had missed putting the colSpeed on, however I am still having trouble with it.
If you move the point slowly it will work most of the time, however if you move the mouse fast or move the colours up and down while still holding the mouse it proper messes up!
I have been looking and looking but can't seem to find my error in the code, I must have something wrong with how I am reading the pointer or something, really not sure.
Can anyone help?
Cheers.
// Project: colour_pallette
// Created: 2015-01-21
// Variables and Arrays
#Constant imgWidth_X = 1280
#Constant imgHeight_Y = 800
colStartPos_X = 1150
colStartPos_Y = 48
colMaxPosUp_Y = -80
colMaxPosDwn_Y = 816
#Constant numColours = 13
colImage as integer[ numColours ]
colButton as integer[ numColours ]
// set display
SetVirtualResolution( imgWidth_X, imgHeight_Y )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate ( 60, 0 )
// Draw the main drawing area as sprite to screen
drawImage = LoadImage ( "/media/PIC1.png" )
drawImageScrNum = CreateSprite( drawImage )
SetSpriteScale( drawImageScrNum, 1.8, 1.86 )
SetSpritePosition ( drawImageScrNum, 0, 0 )
// Turn background sprite on or off (visible) 0 = no 1 = yes
SetSpriteVisible ( drawImageScrNum, 0 )
// Set mouse pointer sprite
pencil = Loadimage ("/media/pencil.png")
pointer = CreateSprite( pencil )
SetSpriteDepth ( pointer, 0 ) // Make sure mouse is on top of screen at all times
// Set up colour sprites
for i = 0 to numColours
colImage [i] = Loadimage ("/media/colours/colour" + str(i) + ".png")
colButton [i] = CreateSprite ( colImage[i] )
SetSpritePosition ( colButton[i] ,colStartPos_X , i * GetSpriteHeight (colImage [i]) - colStartPos_Y )
next i
// Main loop
do
mouseX# = GetPointerX ( )
mouseY# = GetPointerY ( )
// Check for pointer pressed and pointer within colouring screen dimensions if not
// checks for pointer pressed and pointer within colour palette area dimensions
if GetPointerPressed()=1 and mouseX# >= 0 and mouseX# < colStartPos_X and mouseY# >= 0 and mouseY# <= imgHeight_Y
// Waits for the pointer to be released before filling area so doesn't constantly fill
while GetPointerReleased()=0
// This section will have the colour fill routine in the loop
newMouseX# = GetPointerX ( )
newMouseY# = GetPointerY ( )
SetSpritePosition ( pointer, newMouseX#-1 , newMouseY#-90 ) // Draw mouse pointer sprite
Print ("Draw Area Screen")
Print (" ")
Print ("MOUSE X: " + str(newMouseX#))
Print ("MOUSE Y: " + str(newMouseY#))
Print ("FPS: " + str(ScreenFPS()))
Sync()
endwhile
mouseX# = newMouseX#
mouseY# = newMouseY#
elseif GetPointerPressed()=1 and mouseX# >= colStartPos_X and mouseX# <= imgWidth_X and mouseY# >= 0 and mouseY# <= imgHeight_Y
oldMouseY# = GetPointerY ( )
// Waits while the pointer is pressed in order to move colours up and down
while GetPointerReleased()=0
// This section of the loop is for the colour selection
mouseX# = GetPointerX ( )
mouseY# = GetPointerY ( )
if mouseY# < oldMouseY#
// Colours Move Up
colSpeed = oldMouseY# - mouseY#
oldMouseY# = mouseY#
// display colour pallete
for i = 0 to numColours
moveColSprite = GetSpriteY ( colButton [i] ) - colSpeed
if moveColSprite <= colMaxPosUp_Y // -80
if i > 0
moveColSprite = GetSpriteY ( colButton [i-1] ) + GetSpriteHeight( colButton [i] ) - colSpeed
else
moveColSprite = GetSpriteY ( colButton [numColours] ) + GetSpriteHeight ( colButton [i] ) - colSpeed
endif
endif
SetSpritePosition ( colButton[i] ,colStartPos_X , moveColSprite )
next i
elseif mouseY# > oldMouseY#
// Colours Move Down
colSpeed = mouseY# - oldMouseY#
oldMouseY# = mouseY#
// display colour pallete
for i = 0 to numColours
moveColSprite = GetSpriteY ( colButton [i] ) + colSpeed
if moveColSprite => colMaxPosDwn_Y // 816
if i < numColours
moveColSprite = GetSpriteY ( colButton [i+1] ) - GetSpriteHeight( colButton [i] ) + colSpeed
else
moveColSprite = GetSpriteY ( colButton [0] ) - GetSpriteHeight( colButton [i] ) + ColSpeed
endif
endif
SetSpritePosition ( colButton[i] ,colStartPos_X , moveColSprite )
next i
endif
SetSpritePosition ( pointer, mouseX#-1 , mouseY#-90 ) // Draw mouse pointer sprite
Print ("Colour Area Screen")
Print (" ")
Print ("MOUSE X: " + str(mouseX#))
Print ("MOUSE Y: " + str(mouseY#))
Print ("FPS: " + str(ScreenFPS()))
Sync()
endwhile
endif
// Draw mouse pointer
SetSpritePosition ( pointer, mouseX#-1 , mouseY#-90 )
Sync() // Update display
// Check to end program
if GetRawKeyPressed(27)
Exit
endif
loop
Programming - AMOS on the AMIGA! / DBPro / Python / A bit of C &amp;amp;amp;amp;amp;amp;amp;amp;amp; C++ / now also AGK2! Graphics - Deluxe Paint on the Amiga / Paintshop Pro / Photoshop / Lightroom / Grafx2
Previously worked for Prisma Software producing childrens educational software on the Amiga. Titles - Pepe's Garden - Paint Pot / Kids Academy range - Paint Pot II / Shopping Basket / Which Where What? / Blobs / Alvin's Puzzles