Transer Lib

Advanced game related topics
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

Transer Lib

Post by JamieVanCadsand »

Hey 2D Programmers...,

I get here an simple library, called to draw simple 2d radial circles... with given it an count...
Here is the source code, don't edit them.




Source Code:

Code: Select all

;***************************************************************************************************************************
;* Transer.pbi - Version 1.0 ***********************************************************************************************
;***************************************************************************************************************************
;***************************************************************************************************************************
Global X.i = 0
Global Y.i = 0
Global Between.i = 0
Global Radius.i = 0
Global Rotation.i = 0
Global Wave.i = 0
Global Colour.i = 0




;Transer_Circle(X, Y, Between, Radius, Rotation, Count, Colour)
Procedure Transer_Circle_Defeult(X, Y, Between, Radius, Rotation, Count, Colour)
  
  For I = 1 To Count
    Circle(X + (Between * (I * Cos(Radian(Rotation)))), 
           Y + (Between * (I * Sin(Radian(Rotation)))), Radius, Colour)
  Next
  
EndProcedure



;Transer_Circle_Wave(X, Y, Between, Radius, Rotation, Wave, Limit, Count, Colour)
Procedure Transer_Circle_Wave(X, Y, Between, Radius, Rotation, Wave, Count, Colour)
  
  For I = 1 To Count
    Circle(X + (I * (Wave * Cos(Radian(Rotation)))),
           Y + (I * (Wave * Sin(Radian(Rotation)))), Radius, Colour)
  Next
  
EndProcedure
;Transer_Circle_Diffrence(X, Y, Between, Radius, Rotation, Diffrence, Count, Colour)



Procedure Transer_Circle_Diffrence(X, Y, Between, Radius, Rotation, Diffrence, Count, Colour)
  
  For I = 1 To Count
    Circle(X + (Between * (I * Cos(Radian(Rotation * (I * Diffrence))))), 
           Y + (Between * (I * Sin(Radian(Rotation * (I * Diffrence))))), Radius, Colour)
  Next
  
EndProcedure



;Transer_Circle_Bow(X, Y, Between, Radius, Rotation, Diffrence, Count, Colour)
Procedure Transer_Circle_Bow(X, Y, Between, Radius, Rotation, Diffrence, Count, Colour)
  
  For I = 0 To Count
    Circle(X + (Between * (I * Cos(Radian(Rotation + (I * Diffrence))))),
           Y + (Between * (I * Sin(Radian(Rotation + (I * Diffrence))))), Radius, Colour)
  Next
  
EndProcedure



;Transer_Circle_Angle(X, Y, Between, Radius, Rotation, Angle, Count, Colour)
Procedure Transer_Circle_Angle(X, Y, Between, Radius, Rotation, Angle, Count, Colour)
  
  For I = 1 To Count
    Circle(X + (Between * Cos(Radian(Rotation + (Angle * I/Count)))), 
           Y + (Between * Sin(Radian(Rotation + (Angle * I/Count)))), Radius, Colour)
  Next
  
EndProcedure



;***************************************************************************************************************************

Demo Script:

Code: Select all

;******************************************************************************************************
;* Transer Demo 1.0 ************************************************************************************
;******************************************************************************************************


;Import Transer Lib (*.pbi)
XIncludeFile "Transer.pbi"


;Call Rotation Value
Global Rot.i = 0
Global Wave.i = 0
Global Dir.b = 1

;Call Procedure, called Initialize2D
Procedure Initialize2D()
  
  ;Initialize Sprite
  If InitSprite() = 0
    MessageRequester("Fout!", "Kan Sprites niet initializeren!", #PB_MessageRequester_Info)
    End
  EndIf
  
  ;Initializeer Keyboard
  If InitKeyboard() = 0
    MessageRequester("Fout!", "Kan Keyboard niet Initializeren", #PB_MessageRequester_Info)
    End
  EndIf
  
  ;Open Scherm
  If OpenScreen(800, 600, 32, "") = 0
    MessageRequester("Fout!", "Kan Scherm niet Openen", #PB_MessageRequester_Info)
    End
  EndIf
  
EndProcedure


Initialize2D()





Wave * Dir

Repeat
  
  ;Draw Radian Circles
  ClearScreen(0)
  StartDrawing(ScreenOutput())
  Transer_Circle_Defeult(200, 200, 10, 5, Rot, 10, RGB(255, 0, 0))
  Transer_Circle_Diffrence(200, 400, 10, 5, Rot, 1, 10, RGB(0, 255, 0))
  Transer_Circle_Bow(300, 300, 10, 5, Rot, 20, 10, RGB(255, 0, 255))
  Transer_Circle_Wave(500, 300, 10, 5, Rot, Wave, 10, RGB(255, 255, 0))
  Transer_Circle_Angle(600, 400, 100, 5, Rot, 360, 32, RGB(0, 0, 255))
  StopDrawing()
  FlipBuffers()
  
  ;Set Rotation to + 1
  Rot + 1
  
  Wave + (Dir * 1)
  If Wave <= 0 Or Wave >= 32
    Dir = -Dir
  EndIf
  
  ;Exit the demo
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf
  
ForEver

;********************************************************************************************************
Features:
1) Draw Circles on right in an line with rotate it
2) Draw Circles on right in an line with rotate it given it an diffrence value per/circle
3) Draw Circles in an given degrees with rotate it
4) Draw Circles in an wave transformation
5) Draw Circles in an bow
Planned Features 1.1:
1) Draw more Shapes
2) Inner Rotation
Fixed Bugs:
1) StartDrawing..., StopDrawing called in each function...., now you must do call they functions self


This source code is writted by Jamie van Cadsand... you can copy it and paste this in PureBasic...
Version Requered: 5.62..., Jamie
Last edited by JamieVanCadsand on Sun Aug 26, 2018 2:03 pm, edited 7 times in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Radial Circle Library

Post by NicTheQuick »

I don't get it. What is this even doing? Can you give an example?

Maybe you should consider to translate your language into English with DeepL. Then it would be more easy to understand what you are trying to say. ;-)
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Radial Circle Library

Post by Mijikai »

I dont really get what this is supposed to do (i also dont see a library anywhere).
However i suggest this -> dont use StartDrawing() / StopDrawing() in every drawing function (unless u have a good reason).

:?:
Image
User avatar
JamieVanCadsand
User
User
Posts: 34
Joined: Sun Jun 24, 2018 12:28 pm
Location: Holland

Re: Radial Circle Library

Post by JamieVanCadsand »

Mijikai wrote:I dont really get what this is supposed to do (i also dont see a library anywhere).
However i suggest this -> dont use StartDrawing() / StopDrawing() in every drawing function (unless u have a good reason).

:?:
Image
My bug is fixed..., now i get also the demo script...,
Jamie.
User avatar
DK_PETER
Addict
Addict
Posts: 898
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: Radian Lib

Post by DK_PETER »

Copyright and no editing "the script".
You do know that this is extremely basic math, right? :wink:
Current configurations:
Ubuntu 20.04/64 bit - Window 10 64 bit
Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
User avatar
IceSoft
Addict
Addict
Posts: 1616
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Transer Lib

Post by IceSoft »

JamieVanCadsand wrote:...
I get here an simple library, called to draw simple 2d radial circles... with given it an count...
Here is the source code, don't edit them.
...
This source code is writted by Jamie van Cadsand... you can copy it and paste this in PureBasic...
Version Requered: 5.62..., Jamie
@JamieVanCadsand
I see no usubility in this simple library. Any examples? Games? Another ideas for using it?
And why a copyright? For what?
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: Transer Lib

Post by bfernhout »

Guys....

For the people who do not know who this person is:
Jamie is starter in PureBasic and his learning curve is very slow. He does understand the basic work but not all the way. All things around the gaming is unknown by him. So he was thinking that the copyright was somthing else. I explained it to him and now he under stand. All his work he make is under GNU. And all code he post is free to use. The only thing he want to say, is that when you change something in the code and it will not work anymore. He is not te person to adress to for the mistakes you made in the code. That the idea behind it.

His work he showed here is hard work for him and he is very happy to accomplished a challange like this.
His idea to make it a library is for people who has use for it.

Bart.

Good work Jamie. :lol:
From my first self made computer till now I stil like computers.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Transer Lib

Post by wilbert »

Thanks for your post Bart.

Jamie, it’s great you want to share something you created.
I know how it feels when something you put effort in is working :)
Windows (x64)
Raspberry Pi OS (Arm64)
Post Reply