Xojo Conferences
XDCMay2019MiamiUSA

I'm a bit puzzled... (Real Studio games Mailinglist archive)

Back to the thread list
Previous thread: oops
Next thread: [OT] mobile apps IDE ?


[ANN] Preview of RBD 2.4   -   Marc Zeedar
  I'm a bit puzzled...   -   Eric Richards
    I'm a bit puzzled   -   Eric Richards

I'm a bit puzzled...
Date: 15.01.05 02:08 (Sat, 15 Jan 2005 01:08:02 GMT)
From: Eric Richards

Hi -

I've been working hard on this. Everything is
working so far except for running. Now it works
about 98-99% of the time. However I can still get the Knight
to imbed himself into something by only a few pixels and
I have to be trying to get him stuck, which isn't what I want.
It seems it depends on how far away an obstacle is and when I push
the run button that causes it, becuase most of the
time he will stop when he should.

This has me a bit puzzled....

I've included some code. Maybe someone can shed some
light on this?

#When I take the RunSpeed in to the Calc's in TheCornerXY()
The oppset would happen. About 1-2 % of the time the knight
would stop a few pixels away from where he should. Which
seems to depened on the distance from an obstacle and when
I push the run button.

Most greatfull!

Eric

"I have puzzled my puzzler till it could be puzzled no more."

Move()
If keyboard.AsyncShiftKey then// shift aka run
Knight.RunSpeed = 4
else
Knight.RunSpeed = 0
end if

' A B 0 1
'C +---------+ D +---------+
' | | | |
' | | | |
' | | | |
'G +---------+ H +---------+
' E F 2 3

Self.Title = "CornerX: " + str(CornerX) + " CornerY: " + Str(CornerY) + " CornerCol: " + str(CornerCol) + " CornerRow: " + str(CornerRow)
if Keyboard.AsyncKeyDown(&h7E) then //UP
Knight.myDirection = "up"
Knight.frameIndex = ((Knight.FrameIndex+1) mod 3) + 3
theCornerXY(Knight,0)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 Then
//Ok if it's > 0 then there is something there
return
end if
theCornerXY(Knight,1)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 Then
return
end if
Knight.y = (Knight.y -4) - Knight.RunSpeed
return
END IF

if Keyboard.AsyncKeyDown(&h7D) then // DOWN
Knight.MyDirection = "down"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) '+ 3
theCornerXY(Knight,2)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,3)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.y = Knight.y + 4+ Knight.RunSpeed
return
end if
If Keyboard.AsyncKeyDown(&h7c) then //Right
Knight.MyDirection ="right"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 6
theCornerXY(Knight,1)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,3)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.x = (Knight.x + 4)+ Knight.RunSpeed
return
end if
if Keyboard.AsyncKeyDown(&h7b) then //left
Knight.MyDirection ="left"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 9
theCornerXY(Knight,0)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,2)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.x = (Knight.x - 4)- Knight.RunSpeed
return
end if

// Ok if were not pressing any direction keys then set
//the frameindex back to its "normal" position
// for that direction.

If Knight.MyDirection = "up" then
Knight.frameIndex 0 elseif Knight.MyDirection ="down" then
knight.frameIndex= 0
elseif Knight.MyDirection = "right" then
knight.frameIndex = 6
elseif Knight.MyDirection = "left" then
knight.frameIndex  end if

Sub TheCornerXY(Object as HeroClass, WhatCorner as integer)

Select Case Object.MyDirection
Case "up"
if WhatCorner = 0 then
CornerX = (Object.X +4)
CornerY = (Object.Y-2) '-Object.RunSpeed
elseif WhatCorner = 1 then
CornerX = (Object.X +32)-4
CornerY = (Object.Y-2)'- Object.RunSpeed
end if
Case "down"
if WhatCorner = 2 then
CornerX = (Object.X)+4
CornerY = (Object.Y+32)+2'+Object.RunSpeed
elseif whatCorner = 3 then
CornerX = (Object.X+32)-4
CornerY = (Object.Y+32)+2'+Object.RunSpeed
end if
Case "right"
if WhatCorner = 1 then
CornerX = (Object.X+32)+2'+Object.RunSpeed
CornerY = (Object.Y)+4
elseif whatCorner = 3 then
CornerX = (Object.X+32)+2'+Object.RunSpeed
CornerY = (Object.Y+32)-4
end if
Case "left"
if whatCorner = 0 then
CornerX = (Object.X-2)'-Object.RunSpeed
CornerY = (Object.Y)+4
elseif whatCorner = 2 then
CornerX = (Object.X-2)'-Object.RunSpeed
CornerY = (Object.Y+32)-4
end if
end select
TheCornerColRow
End Sub

Sub TheCornerColRow()
CornerCol = (CornerX\32)
CornerRow = (CornerY\32)

End Sub

___________________________________________________________________
Speed up your surfing with Juno SpeedBand.
Now includes pop-up blocker!
Only $14.95/month -visit http://www.juno.com/surf to sign up today!

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

I'm a bit puzzled
Date: 15.01.05 03:43 (Sat, 15 Jan 2005 02:43:50 GMT)
From: Eric Richards

Hi -

I've been working hard on this. Everything is
working so far except for running. Now it works
about 98-99% of the time. However I can still get the Knight
to imbed himself into something by only a few pixels and
I have to be trying to get him stuck, which isn't what I want.
It seems it depends on how far away an obstacle is and when I push
the run button that causes it, becuase most of the
time he will stop when he should.

This has me a bit puzzled....

I've included some code. Maybe someone can shed some
light on this?

#When I take the RunSpeed in to the Calc's in TheCornerXY()
The oppset would happen. About 1-2 % of the time the knight
would stop a few pixels away from where he should. Which
seems to depened on the distance from an obstacle and when
I push the run button.

Most greatful!

Eric

Move()
If keyboard.AsyncShiftKey then// shift aka run
Knight.RunSpeed = 4
else
Knight.RunSpeed = 0
end if

' A B 0 1
'C +---------+ D +---------+
' | | | |
' | | | |
' | | | |
'G +---------+ H +---------+
' E F 2 3

Self.Title = "CornerX: " + str(CornerX) + " CornerY: " + Str(CornerY) + " CornerCol: " + str(CornerCol) + " CornerRow: " + str(CornerRow)
if Keyboard.AsyncKeyDown(&h7E) then //UP
Knight.myDirection = "up"
Knight.frameIndex = ((Knight.FrameIndex+1) mod 3) + 3
theCornerXY(Knight,0)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 Then
//Ok if it's > 0 then there is something there
return
end if
theCornerXY(Knight,1)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 Then
return
end if
Knight.y = (Knight.y -4) - Knight.RunSpeed
return
END IF

if Keyboard.AsyncKeyDown(&h7D) then // DOWN
Knight.MyDirection = "down"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) '+ 3
theCornerXY(Knight,2)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,3)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.y = Knight.y + 4+ Knight.RunSpeed
return
end if
If Keyboard.AsyncKeyDown(&h7c) then //Right
Knight.MyDirection ="right"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 6
theCornerXY(Knight,1)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,3)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.x = (Knight.x + 4)+ Knight.RunSpeed
return
end if
if Keyboard.AsyncKeyDown(&h7b) then //left
Knight.MyDirection ="left"
Knight.frameIndex =((Knight.FrameIndex+1)mod 3) + 9
theCornerXY(Knight,0)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
theCornerXY(Knight,2)
if TileIDAtColRow(3,CornerCol,CornerRow) > 0 then
return
end if
Knight.x = (Knight.x - 4)- Knight.RunSpeed
return
end if

// Ok if were not pressing any direction keys then set
//the frameindex back to its "normal" position
// for that direction.

If Knight.MyDirection = "up" then
Knight.frameIndex 0 elseif Knight.MyDirection ="down" then
knight.frameIndex= 0
elseif Knight.MyDirection = "right" then
knight.frameIndex = 6
elseif Knight.MyDirection = "left" then
knight.frameIndex  end if

Sub TheCornerXY(Object as HeroClass, WhatCorner as integer)

Select Case Object.MyDirection
Case "up"
if WhatCorner = 0 then
CornerX = (Object.X +4)
CornerY = (Object.Y-2) '-Object.RunSpeed
elseif WhatCorner = 1 then
CornerX = (Object.X +32)-4
CornerY = (Object.Y-2)'- Object.RunSpeed
end if
Case "down"
if WhatCorner = 2 then
CornerX = (Object.X)+4
CornerY = (Object.Y+32)+2'+Object.RunSpeed
elseif whatCorner = 3 then
CornerX = (Object.X+32)-4
CornerY = (Object.Y+32)+2'+Object.RunSpeed
end if
Case "right"
if WhatCorner = 1 then
CornerX = (Object.X+32)+2'+Object.RunSpeed
CornerY = (Object.Y)+4
elseif whatCorner = 3 then
CornerX = (Object.X+32)+2'+Object.RunSpeed
CornerY = (Object.Y+32)-4
end if
Case "left"
if whatCorner = 0 then
CornerX = (Object.X-2)'-Object.RunSpeed
CornerY = (Object.Y)+4
elseif whatCorner = 2 then
CornerX = (Object.X-2)'-Object.RunSpeed
CornerY = (Object.Y+32)-4
end if
end select
TheCornerColRow
End Sub

Sub TheCornerColRow()
CornerCol = (CornerX\32)
CornerRow = (CornerY\32)

End Sub

___________________________________________________________________
Speed up your surfing with Juno SpeedBand.
Now includes pop-up blocker!
Only $14.95/month -visit http://www.juno.com/surf to sign up today!

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>