Author Topic: Hiccups  (Read 2934 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Hiccups
« on: September 22, 2011, 08:27:54 AM »
Deleted
« Last Edit: April 11, 2015, 09:56:19 AM by Peter »

Charles Pegge

  • Guest
Re: Hiccups
« Reply #1 on: September 22, 2011, 12:15:30 PM »
Peter,
We have a LoadBmp incompatibility so I can't run the Frog.

But you could try making this change


r  +=2: iF r>=360 Then r =-360

r  +=2: iF r>=360 Then r -=360

Charles

PS: current version of Loadbmp in window.h

Code: OxygenBasic
  1. Function LoadBmp(string File, sys width, height) as sys
  2. static id as sys: id +=1
  3. iHnd(id) = LoadImage(0,File,0,0,0,16)
  4. iHdc(id) = CreateCompatibleDC(sys_hdc)
  5. SelectObject iHdc(id), iHnd(id)
  6. imgW(id) = width
  7. imgH(id) = height
  8. Function = id
  9. End Function
  10.  
       




« Last Edit: September 22, 2011, 12:18:02 PM by Charles Pegge »

Peter

  • Guest
Re: Hiccups
« Reply #2 on: September 22, 2011, 03:26:25 PM »
Hi Charles,

You have got a wrong  Window.h version!
You must it only accommodate on your oxygen.dll!
I use at present  version o36

« Last Edit: July 07, 2013, 10:42:30 AM by peter »

Charles Pegge

  • Guest
Re: Hiccups
« Reply #3 on: September 22, 2011, 09:32:23 PM »

Yes that's better, I am now using the 10 Sept Version included with 'Happy particles'

Try changing sin to cos. It is a phasing problem

Setbmp frog,x+cos(radians r*pi)*180,y+sin(radians r*pi)*40,128,128,zK


My froggy test:
Code: [Select]
indexbase 0
Include "window.h"

SetWindow "SineAnimation",640,480,w_1
SetFont 12,24,100,"courier"

sys bild,gras,frog,zk,x=240,y=310
single r1,r2,ra,ri1,ri2
bild= LoadBmp "bmp/stern.bmp",1
gras= LoadBmp "bmp/grass.bmp",1
frog= LoadBmp "bmp/frog.bmp",2
ri1=2
ri2=40
While WinExit=0
SetBmp bild,0,0,640,480,0
SetBmp gras,0,480-90,800,64,0
Setbmp frog,x+cos(rad r1)*r1*.8,y+cos(rad r2)*20,128,128,zK
SetText "Radian = " + rad(r1), 0, 0,Rgb 255,255,255
SetText "Radius = " + r1 ,0,26,Rgb 255,255,255
'zK +=1: iF zK = 2 Then zK=0
r1 +=ri1 : iF r1<0 or r1>360 Then ri1=-ri1 : r1+=ri1*2
r2 +=ri2 : iF r2<0 or r2>360 Then ri2=-ri2 : r2+=ri2*2
DoEvents
SwapBuffers
WaitFrames 8
Wend
WinEnd

Charles

Peter

  • Guest
Re: Hiccups
« Reply #4 on: September 23, 2011, 02:55:00 AM »
Hi Charles,

Super Froggy by you!  It is not a phase error!
This has the intent to go, without trouble. can you understand why Rad not works correctly here ?

Code: [Select]
indexbase 0
Include "window.h"

SetWindow "SineAnimation",640,480,w_1
SetFont 12,24,100,"courier"

sys bild, gras, frog, zk, x=256, y=310
Single r, ra

bild= LoadBmp "bmp/stern.bmp",1
gras= LoadBmp "bmp/grass.bmp",1
frog= LoadBmp "bmp/frog.bmp",2

While WinExit=0
SetBmp bild,0,0,640,480,0
SetBmp gras,0,480-90,800,64,0
Setbmp frog,cos(r*pi/180)*180+x,sin(r*pi/180)*10+y,128,128,zK
Setbmp frog,-cos(r*pi/180)*180+x,sin(r*pi/180)*50+100,128,128,zK

ra = rad r
SetText "Radian = " + ra,0, 0,Rgb 255,255,255
SetText "Radius = " + r ,0,26,Rgb 255,255,255
'zK +=1: iF zK = 2 Then zK=0
r  +=4: iF r>=360 Then r= -360
DoEvents
SwapBuffers
WaitFrames 18
Wend
WinEnd

Charles Pegge

  • Guest
Re: Hiccups
« Reply #5 on: September 23, 2011, 03:56:32 AM »
Hi Peter,

I would advise using explicit brackets with all the maths functions (due to precedence).

Also to calculate sin and cos as little as possible.

ra = rad (r)
ca = cos (ra)
sa = sin (ra*8 )


More Bouncy frogs :)

Code: [Select]
indexbase 0
Include "window.h"

SetWindow "SineAnimation",640,480,w_1
SetFont 12,24,100,"courier"

sys bild, gras, frog, zk, x=256, y=310
Single r, ra,ca,sa

bild= LoadBmp "bmp/stern.bmp",1
gras= LoadBmp "bmp/grass.bmp",1
frog= LoadBmp "bmp/frog.bmp",2

While WinExit=0
SetBmp bild,0,0,640,480,0
SetBmp gras,0,480-90,800,64,0

ra = rad (r)
ca = cos (ra)
sa = sin (ra*8)

Setbmp frog,ca*180+x,sa*20+y,128,128,zK
Setbmp frog,-ca*180+x,sa*50+100,128,128,zK

SetText "Radian = " + ra,0, 0,Rgb 255,255,255
SetText "Radius = " + r ,0,26,Rgb 255,255,255
'zK +=1: iF zK = 2 Then zK=0
r  +=4: iF r>=360 Then r= -360
DoEvents
SwapBuffers
WaitFrames 18
Wend
WinEnd

Charles


Peter

  • Guest
Re: Hiccups
« Reply #6 on: September 23, 2011, 04:33:37 AM »
The Frogs hop funny their way.   :D
I have found the mistake which I am making.

sin(radians r*pi/180)  this is wrong!
sin(radians r)            this is right!
 
Sometimes I am really blind.   :D
« Last Edit: September 23, 2011, 04:41:25 AM by peter »

Peter

  • Guest
Re: Hiccups
« Reply #7 on: September 23, 2011, 04:34:22 AM »
Did you know that " DOS = denial of service"  means?
And they are doing it furthermore.

And I was thinking DOS is an operation system by Bill Gates.