December 04, 2020, 02:03:53 PM

Author Topic: Why I Love this forum  (Read 4615 times)

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1136
Why I Love this forum
« on: December 28, 2018, 07:37:32 AM »
I was hunting around for a recent thread regarding drawing circles which got the creative cogs nearly grinding into life.

In my searching I came across some code for plotting some points and allowing them to be moved.

I thought it'd be interesting to add the ability to add some more points, or remove them if you felt like it.

[EDIT]

for those of you without a Blitz esque compiler, heres a link to an executable:



circles2.exe  circles2.exe




Here's the code in all it's glory - it'll run in Blitz3D and probably BlitzPlus.....

Code: [Select]
; Original author Credit:
; https://www.syntaxbomb.com/index.php/topic,2714.msg3703.html#msg3703

; Version 0.2
; Adding mouse cursor info to allow for capture of additional datapoints:
; Completed 28 Dec 18, by 3DZforMe, aka Blitzplotter

; Set the screensize
Graphics 800,600,32,2
SetBuffer BackBuffer()

MaxNumberOfPoints=200
Global CurrentPlotCount=4
Global NextPlotCount=5

; Dimension the pointarray and set startvalues
Dim DataPoint(MaxNumberOfPoints,1)
DataPoint(0,0) = 100 : DataPoint(0,1) = 090
DataPoint(1,0) = 200 : DataPoint(1,1) = 160
DataPoint(2,0) = 300 : DataPoint(2,1) = 300
DataPoint(3,0) = 400 : DataPoint(3,1) = 210
DataPoint(4,0) = 500 : DataPoint(4,1) = 100

    ; Set the clearcolor to red, and select point 0
ClsColor 255,255,255 : Global Selected = 0

    ; Mainloop
While Not KeyDown(1)
Cls ; Clear screen

       ; Userinput (Use [Q] and [W] to select a point,
       ; and Arrowkeys to position the selected point)
If KeyHit(16) And Selected > 0 Then Selected = Selected - 1
If KeyHit(17) And Selected < CurrentPlotCount Then Selected = Selected + 1
If KeyDown(203) Then DataPoint(Selected,0) = DataPoint(Selected,0) - 1
If KeyDown(205) Then DataPoint(Selected,0) = DataPoint(Selected,0) + 1
If KeyDown(200) Then DataPoint(Selected,1) = DataPoint(Selected,1) - 1
If KeyDown(208) Then DataPoint(Selected,1) = DataPoint(Selected,1) + 1

DrawLine(CurrentPlotCount) ; Draw the interpolated line between point 0 and 4

xP=MouseX()
yP=MouseY()

Color 0,0,250

Text 40,1,"Userinput: (Use [Q] and [W] to select a point, and Arrowkeys to Move the selected point"

Color 100,180,0

Text 12,30,"x: "+xP+" y: "+yP+" Points to Draw:"+CurrentPlotCount

;If left click add extra position to current list of points

button$="No"
If MouseDown(1) Then button$="Left"
If MouseDown(2) Then button$="Right"
If MouseDown(3) Then button$="Middle"

Text 400,30, button$ + " mouse button pressed!"

If button$="Left"

DataPoint(NextPlotCount,0) = xP : DataPoint(NextPlotCount,1) = yP
CurrentPlotCount=CurrentPlotCount+1
NextPlotCount=NextPlotCount+1

;Implement a pause to stop NUMEROUS extra points being added in quick succesion

Text 40,60,"Press any key to continue to add your next point"

Flip

WaitKey()

EndIf

If button$="Right"

DataPoint(NextPlotCount,0) = xP : DataPoint(NextPlotCount,1) = yP

If CurrentPlotCount>1

CurrentPlotCount=CurrentPlotCount-1
NextPlotCount=NextPlotCount-1

Text 40,60,"Press any key to continue....."

Flip

WaitKey()

Else

Text 40,60,"Add some more points first please....."

;Implement a pause to stop NUMEROUS extra points being added in quick succesion

Text 40,80,"Press any key to continue....."

Flip

WaitKey()


EndIf


EndIf

If button$="Middle"

Text 200,50,"Congratutaions on 3 buttons...."

EndIf


Flip ; Flip backbuffer to frontbuffer
Wend

End ; End of programm

Function DrawLine(CurrentPlotCount)
       ; Startpoint for the first Line
X = DataPoint(0,0) : Y = DataPoint(0,1) : Color 0,0,0

       ; Draw the interpolyted Line between point 0 and 1
MX = (DataPoint(0,0) - DataPoint(1,0)) * (-1)
For MU# = 0 To 1.0 Step 0.08
OX = X : OY = Y
Y = CosineInterpolate(DataPoint(0,1),DataPoint(1,1),MU#)
X = MX * MU# + DataPoint(0,0)
Line OX,OY,X,Y
Next

       ; Draw the interpolated line between point 1 and 4
For I = 2 To CurrentPlotCount
MX = (DataPoint(I - 1,0) - DataPoint(I,0)) * (-1)
For MU# = 0 To 1.0 Step 0.08
OX = X : OY = Y
Y = CosineInterpolate(DataPoint(I - 1,1),DataPoint(I,1),MU#) 
X = MX * MU# + DataPoint(I - 1,0)
Line OX,OY,X,Y
Next
Next

       ; Dra the anchor points
Color 255,0,0
For I = 0 To CurrentPlotCount
If Selected = I Then
Color 0,0,255
Else
Color 255,0,0
EndIf
Oval DataPoint(I,0) - 2,DataPoint(I,1) - 2,5,5,1
Next
End Function

    ; Function for cosineinterpolated line
Function CosineInterpolate(Y1#,Y2#,MU#)
Local MU2#
MU2# = (1.0 - Cos(MU# * 180.0))/2.0
Return (Y1# * (1.0 - MU2#) + Y2# * MU2#)
End Function

    ; Function for normal line
Function LinearInterpolate(Y1#,Y2#,MU#)
Return Y1# * (1 - MU#) + Y2# * MU#
End Function


Right, coding done for the day.... off to pack for a cheeky 300 mile drive to Scotland ;)

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 166
Re: Why I Love this forum
« Reply #1 on: December 28, 2018, 11:09:50 AM »
I remember that i have a problem with bb3d exe´s.
I have only a black colored window.
Must i install any feature in windows 10?

DirectPlay is installed.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 16GB Ram - 240GB SSD

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: Why I Love this forum
« Reply #2 on: December 28, 2018, 04:23:35 PM »
I remember that i have a problem with bb3d exe´s.
I have only a black colored window.
Must i install any feature in windows 10?

DirectPlay is installed.

We need a bit more information to help.
Can you run the code within the example folder from the IDE without issue?
Does compiling the same code into an .exe produce the same result?
Do you have the full installation of DX9c on your system? Windows 10 does not come with it standard.
Multiple monitors will cause issues with Blitz. Unless the program ran is displayed on your primary screen it will show up blank/blackscreen but still function in the background.
Lastly do you have any global settings on your 3D card? I would have it set for "application preference" or whatever is equivalent to your card.
Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 166
Re: Why I Love this forum
« Reply #3 on: December 28, 2018, 05:13:41 PM »
I just start the .exe
In past (a few month ago i tried some codes with bb3d) i have the same problem.
Sometimes it go well sometime not.
Dx9c is installed.
Driver up2date, nothing special configured in the settings.

I start the exe and it opens a normal bordered window with a black background...thats all.
But not very important that i must this issue solve now ;)
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 16GB Ram - 240GB SSD

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: Why I Love this forum
« Reply #4 on: December 28, 2018, 07:34:10 PM »
Do 2d examples always work? Meaning its only the 3D examples that give you this issue?

I have noticed on Windows 7 sometimes at random when I build an .exe it does not link everything together correctly, resulting in a "missing library" error. Recompiling until it works solves the issue.

Please let me know what code you are attempting to run.

Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1136
Re: Why I Love this forum
« Reply #5 on: December 28, 2018, 08:19:53 PM »
Sorry to hear your trouble with the executable, just downloaded it to my dad's laptop in Scotland, not that the country should matter much, it's a windows10 box, sure it needed .  ....   Gotta go for my yea, it worked after installing directplay though ;)

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 166
Re: Why I Love this forum
« Reply #6 on: December 28, 2018, 08:50:33 PM »
I only wanted to run the exe.There is no reason for me to play around with bb3d.
But that demonstrates that bb3d is sometimes just to old.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 16GB Ram - 240GB SSD

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1136
Re: Why I Love this forum
« Reply #7 on: December 28, 2018, 09:40:42 PM »
I suspect it's compatibility lssues with your 3d card, I was surprised it ran on my dad's old laptop, and I didn't need to install Blitz3D for the exe to work, even though the screen grab shows otherwise. I was just intrigued to see if my dad's clunky computer could compile blitz stuff. Sorry it didn't work for you though.

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 166
Re: Why I Love this forum
« Reply #8 on: December 28, 2018, 09:43:56 PM »
its no problem.
that issue is only with bb3d´s builds.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 16GB Ram - 240GB SSD

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: Why I Love this forum
« Reply #9 on: December 29, 2018, 03:10:46 AM »
I only wanted to run the exe.There is no reason for me to play around with bb3d.
But that demonstrates that bb3d is sometimes just to old.

I'm going to guess and say that English isn't your first language? I was under the impression you were trying to compile the code yourself. The problem you're having is not Blitz related but likely your hardware or something else specific to your system.
Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 166
Re: Why I Love this forum
« Reply #10 on: December 29, 2018, 08:10:07 AM »
Right ;)
And i start only circles2.exe
Maybe its hardware related that my chipset doesn´t allow the dx7 emulated things.I don´t know.Its not important.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 16GB Ram - 240GB SSD

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1136
Re: Why I Love this forum
« Reply #11 on: December 29, 2018, 10:48:02 AM »
I'm jealous of folks with 64 bit hardware, all my Dev machines are only (only....!) 32 bit so aren't Cerberus compatible. I'm also an advocate of MonkeyX despite the fact the forums vanished. On my dad's W10 computer (I've only got W7, tbh it's like today's XP OS), it was taking for EVER to locate directplay, nearly gave up and went hunting on the web.... But it eventually found it. Was the only hiccup, I'd be surprised if he's got older DirectX versions but you never know!

Offline MagosDomina

  • Full Member
  • ***
  • Posts: 121
    • Aspiring game developer website.
Re: Why I Love this forum
« Reply #12 on: December 29, 2018, 02:39:53 PM »
There is a way to strip a Blitz exe of the direct-play requirement. I found it on a German based Blitz website and archived it on a drive. If I remember correctly the direct play requirement is only for the multiplayer compatibility. So if your app doesn't use any of those functions you can strip out request for the .dll thus removing the need for Windows 10 to install this legacy component.


*edit*

Here is what you do, open runtime.dll in the blitz3d\bin folder into a hex editor. Search for Dplayx.dll and replace it with Dinput.dll and save it.
This only works with Blitz3d and lets you run your code without direct play.
Central hub for my Game Design related activities.
http://www.magosdomina.com/

Windows 7 PRO 64-bit, 48Gb RAM, CPU: Dual Hexacore Intel Xeon 3.33 GHZ, Nvidia Quadro 5800FX 4Gb x 2 SLI.

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 1136
Re: Why I Love this forum
« Reply #13 on: December 30, 2018, 03:47:57 AM »
Great piece of advice, thanks for sharing!

I think I recall Blitz3D may need a dedicated graphics card to run, some of the on motherboard graphics cards may not be up to the job .

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1081
Re: Why I Love this forum
« Reply #14 on: December 30, 2018, 09:23:30 AM »
Quote
I think I recall Blitz3D may need a dedicated graphics card to run
what are you talking about ? how do you know that ? i have run blitz3d (3d) programs on many different laptops / desktops without having ever noticed this !!!


maybe consider that your code is the problem ?
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal