Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - benny!

Pages: 1 2 3 4 5 [6] 7
101
Preface

Inspired by this thread http://dbfinteractive.com/index.php?topic=1585.0
I decided to have a go with c++ using the NET framework.

Generally ppl tend to use the NET framework with languages like C#, J#
or maybe VB.NET. But you can use "normal" C++ to code NET framework
application as well.

In the following I describe the steps to create an C++ project using
the NET framework with Visual Suite Express 2005 edition.


Step 01 - Create the Project

Create a new Visual C++ project [ File -> New -> Project ... ]. Then
select CLR as the Project Type. And for easy GUI development
choose the Windows Forms Application as Template.
Enter a name (e.g. CppWithClr ) and press OK.


Step 02 - Create the GUI

Now you can easily draw the GUI with the DESIGN View of your
Form. You should see an empty Window with the Title Form1.
Use the toolbar to the right and add for this example a Textbox
and a button to the window.
( You to this by just drawing them on the window after you selected
them from the toolbar
)


Step 03 - Modify form and control properties

As you can see, the button has the text button1 on it and in the
title bar of our window stands Form1 which isnt very "cool".
To change the properties of any GUI element just simply right click
on it and you got to the property-panel of this gui element.

In our case - you might right-click the button, choose Properties
and edit the Text under Appearance to your desire.

The same you can do with the window title. Simple right-click on a
spare region in the window and change the TEXT under apperance.


Step 04 - Add program code

Adding some program code it comparable easy. Just double click on our
button and you switch to the code-view of our Form1 code. There you
can see that by clicking on our button the IDE automatically created
the button_Click event function (this is executed, when you
press the button).

And right in this method we can put our code.

For now, we only want to show some text in our textbox we created - the
name of our textbox as long as we didn't change it - should be
textBox1[/b]. Updating text in a textbox is comparably easy. Just add
the following code :
Code: [Select]
textBox1->Text = \
"Hello world from C++ with CLR";


Step 05 - Test the application

Now save your application and test it by pressing F5.


The generated code looks like the following :

The main method looks like this ( its auto-generated ... )

Code: [Select]
#include "Form1.h"

using namespace CppWithClr2;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}

Our Form1.h to which we added our little actin routine looks like
this :
Code: [Select]
#pragma once


namespace CppWithClr2 {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
///          'Resource File Name' property for the managed resource compiler tool
///          associated with all .resx files this class depends on.  Otherwise,
///          the designers will not be able to interact properly with localized
///          resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^  textBox1;
protected:
private: System::Windows::Forms::Button^  button1;

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(43, 19);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(198, 20);
this->textBox1->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(47, 50);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(193, 32);
this->button1->TabIndex = 1;
this->button1->Text = L"Show HelloWorld";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 94);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"HelloWorld C++/CLR";
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
textBox1->Text = \
"Hello world from C++ with CLR";
}
};
}


I added the created executable to this post. To run it you need the NET framework to
be installed on your system.

102
General chat / Programming Games
« on: March 18, 2007 »
Hi all.

I was stumbling about some some programming games lately and wonder who of
you are actually playing some of them or are interesting in it.

The idea of programming games is to motivate / help ppl to learn to program a
certain programming language or just to have fun. You do not control your player
object via mouse / cursor keys like in a normal game. You have to code a programm
( something like a KI ) that controls the movement / action of your player.

To find out more about - here are some links to some games I found :

RobotBattle

JRobots

RoboCom

Crobots

RoboWar

RoboCode

AntMe (german site)

Would be interesting to know - if you ever played such a game ( if so - which ? ) and what
you generally think about those kind of games ?

103
General chat / C# - What do you think about it ?
« on: March 18, 2007 »
Hi.

I wonder what you guys think about C# ? Does anyone has any experience with it ?

I am interesting in the pro and cons concerning in the following fields of this language :


* Game Development ( Windows and WindowsMobile )

* Application Development ( Webservices, WindowsMobile and Windows Applications )

* other Demo- / Multimediadevelopment ?


If you already knew Java development - it would be really interesting to know the
comparision from C# to Java.

Btw. Who has the .NET Framework installed on his machine?

104
Purebasic / something round.
« on: March 14, 2007 »
Just a little small conversion of an old demoFX. Enjoy!

Exe attached for those without purebasic

Code: [Select]
; something round.
; a conversion of an old demoFX
; by benny|weltenkonstrukteur.de
; o8.o6.o5

winTitle.s  = "something round."
#LOOPTIME   = 1000/14  ; 40 Frames in 1000ms (1second)

hwnd.l = OpenWindow(0, 0,0, 320, 240, winTitle.s, #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If hwnd
  If InitSprite()
    If OpenWindowedScreen(hwnd, 0, 0, 320, 240, 0, 0, 0)
     
        Dim px.f(15)
        Dim py.f(15)
       
        Repeat   
         
          Select WindowEvent()
            Case #PB_Event_CloseWindow
              Quit = #True
          EndSelect
         
          FlipBuffers()
          If IsScreenActive() 
            ClearScreen(RGB(0,0,0) )
            StartDrawing(ScreenOutput())
                DrawingMode( #PB_2DDrawing_XOr)
                px(0) = 160+8*Cos(a.f)
                py(0) = 120+8*Sin(a.f)
                For i=1 To 14 Step 2
                  px(i-1) = px (i)
                  py(i-1) = py (i)
                  px(i) = 160+8*Cos (a.f * (1+i*0.1))
                  py(i) = 120+8*Sin (a.f * (1+i*0.1))
                  Circle(px(i), py(i), 110-i*8, RGB(155,155,155))
                Next i
                a + 0.4
                StopDrawing()
          EndIf
         
          ; Run Program at a constant rate 
          While ( ElapsedMilliseconds()-LoopTimer )<#LOOPTIME : Delay(1) : Wend 
          LoopTimer = ElapsedMilliseconds()
        Until Quit = #True
       
    EndIf
  EndIf
EndIf
End

105
GFX & sound / [SEEKING] V2M music resources
« on: March 14, 2007 »
Hi.

Does anyone of you know resource sites like modarchive where you can
download music tracks in the .v2m format ?

Note: The .v2m format is the well known format by kb^farbrausch synth-
system used amongst others in demos like .the product

106
General chat / [FlashGame] Binary Game
« on: March 13, 2007 »
lol ... just discovered a flash game by Cisco Systems called Binary game.
A nice way to learn the binary system. Here is the link for it :

http://forums.cisco.com/CertCom/game/binary_game_page.htm

Note: I didnt want to post it in the useful links section because it is "just" a
flash game.

107
Useful links / Good freeware tools
« on: March 13, 2007 »
Hi.

I decided to open this thread so everyone can add links to good freeware programs
you can recommend. Please do only post real freeware programs in this thread.
So, no shareware or adware please.

I start off with the following links:

XNVIEW ( http://www.xnview.com/ )
Its an outstanding graphic and photo viewer with several picture manipulations and fx
features. Furthermore, you can create batch files for converting e.g. a large amount
of pictures.

ECLIPSE ( http://www.eclipse.org/ )
Very powerful IDE for various languages and purposes!


108
Java,JS & Flash / Processing
« on: March 08, 2007 »
Hi.

I want to share the following link with you. It is an open source programming language to easily create
Java applets.

http://processing.org/

Here is the official quote from the entry page :
Quote
Processing is an open source programming language and environment for people who want to program
images, animation, and sound. It is used by students, artists, designers, architects, researchers, and
hobbyists for learning, prototyping, and production. It is created to teach fundamentals of computer
programming within a visual context and to serve as a software sketchbook and professional production
tool. Processing is developed by artists and designers as an alternative to proprietary software tools in
the same domain.

If you are interested, here are some examples by GHOSTAGENCY :

http://www.ghostagency.net/processing/sketch_cubo_fractal/index.html

http://www.ghostagency.net/processing/spyro_study/index.html

http://www.ghostagency.net/processing/relations_var1/index.html

109
"In 20 sec..."

Here is my entry for the 20SECONDS competition. I couldnt think of a special
fx that fits to the compo's theme. That's why I focus more on the message  :-\

So. No real eyecandy - I'm sorry.

Download it here (approx. 750kb)

http://www.weltenkonstrukteur.de/dl/in20sec.rar

UPDATED LINK
http://www.dbfinteractive.com/downloadshow.php?dl_id=26

Credits:

sound-track:     xtd / mystic & pulse
sound-system:   fmod
video-sequence:   nuclearweaponarchive.org
code/design:    benny!

110
Purebasic / auld's 4kb framework for purebasic 4.0
« on: February 28, 2007 »
Conversion of auld's 4kb framework ported to the current version of
purebasic. attached example file is 2.560 bytes uncompressed.

Code: [Select]
; *** 4K Framework for PureBasic [Win]
; ***
; *** original framework by auld
; *** pb-conversion by benny!weltenkonstrukteur.de
; ***

IncludeFile "OpenGL.pbi"


Procedure do4KIntro()

glClear_(#GL_DEPTH_BUFFER_BIT | #GL_COLOR_BUFFER_BIT);
  glRotatef_(0.5,1.0,1.0,1.0);
glBegin_(#GL_TRIANGLES);
glColor3f_(1.0,0.0,0.0);
glVertex3f_(0.0,-1.0,0.0);

glColor3f_(0.0,1.0,0.0);
glVertex3f_(1.0,1.0,0.0);

glColor3f_(0.0,0.0,1.0);
glVertex3f_(-1.0,1.0,0.0);
glEnd_();

EndProcedure


pfd.PIXELFORMATDESCRIPTOR
pfd\cColorBits  = 32
pfd\cDepthBits  = 32
pfd\dwFlags     = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER
hDC = GetDC_ ( CreateWindow_("edit", 0, #WS_POPUP | #WS_VISIBLE | #WS_MAXIMIZE, 0, 0 ,0 ,0, 0 ,0 ,0, 0 ) )
SetPixelFormat_ ( hDC, ChoosePixelFormat_( hDC, pfd), pfd )
wglMakeCurrent_ ( hDC, wglCreateContext_(hDC) )
ShowCursor_(#False);

Repeat
  glClear_ ( #GL_DEPTH_BUFFER_BIT | #GL_COLOR_BUFFER_BIT )
  do4KIntro()
  SwapBuffers_ ( hDC );
Until ( GetAsyncKeyState_ (#VK_ESCAPE) )

111
Purebasic / XMas tree for purebasic 4.0
« on: February 28, 2007 »
Hi.

Today I converted some old code ( december 2oo4 ) to the actual version
of purebasic. Furthermore, the old code needs some 3rd party opengl user
library. The new code doesnt. You can compile it with the current version
of PureBasic V4.0.

Code: [Select]

;##################################
;##  XMas Tree in some kilobytes
;##           for the
;##     Pure Winter Contest
;##          Dec.2004
;##             by
;##  benny^weltenkonstrukteur.de
;##
;## Note:
;## This was done in quite a hurry
;## (1 afternoon). In addition I am
;## suffering from a glue. So excuse
;## buggy code.
;##
;## Anyway,
;##
;##  Merry X-Mas And a Happy New Year!
;##


;## Converted to PB4.0 on 28.Feb.2007

XIncludeFile "OpenGL.pb"

;##################################
;## Constants, Globals ...

Import "glu32.lib"
 gluPerspective(fovy.d,aspect.d,zNear.d,zFar.d) ;sets up a perspective projection matrix
 gluLookAt(eyex.d,eyey.d,eyez.d,centerx.d,centery.d,centerz.d,upx.d,upy.d,upz.d) ;defines a viewing transformation
EndImport


Declare InitSnow(snowflake.l)

Structure SnowFlake
  state.l ; 0 = Snowing / alive
          ; 1 = Dying / on ground 
  transX.f
  transY.f
  transZ.f
  downZ.f
  color.f
EndStructure

#WindowWidth = 640
#WindowHeight = 480
#numFLAKES = 200

Global hWnd.l

Dim Flakes.SnowFlake(#numFLAKES)
For z=0 To #numFLAKES-1
  InitSnow(z)
Next z

Procedure WindowCallback(Window,Message,wParam,lParam)
  Static small
  Select Message
    Case #WM_SIZE
      If small = 1
        glViewport_(0, 0, GetSystemMetrics_(#SM_CXSCREEN) , GetSystemMetrics_(#SM_CYSCREEN) )
        small = 0
      Else
        glViewport_(0, 0, #WindowWidth , #WindowHeight )
        small = 1
      EndIf
      Result = DefWindowProc_(Window,Message,wParam,lParam)
    Case #WM_DESTROY
      DestroyWindow_(Window)
      PostQuitMessage_(0)
      End
      ProcedureReturn 0
    Default
      Result = DefWindowProc_(Window,Message,wParam,lParam)
  EndSelect
  ProcedureReturn Result
EndProcedure


Procedure InitSnow(snowflake.l)
  Shared Flakes()
  Flakes(snowflake)\state = 0
  Flakes(snowflake)\transX = 1.0 - (Random(20) / 10)
  Flakes(snowflake)\transY = 1.0 - (Random(20) / 10)
  Flakes(snowflake)\transZ = 2.4 + Random(2)
  Flakes(snowflake)\downZ  = Random(10) / 1000 + 0.004
  Flakes(snowflake)\color  = 0.8
EndProcedure
 
;##################################
;## Setting the whole thing up.

#Style   = #WS_VISIBLE | #WS_SYSMENU | #WS_MAXIMIZEBOX
#StyleEx = #WS_EX_OVERLAPPEDWINDOW

WindowClass.s = "MeinFenster"
wc.WNDCLASSEX
wc\cbSize        = SizeOf(WNDCLASSEX)
wc\lpfnWndProc   = @WindowCallback()
wc\lpszClassName = @WindowClass
RegisterClassEx_(@wc)

hWnd = CreateWindowEx_( #StyleEx,WindowClass,"xmas tree in 4kb ;-) | pure winter contest 2oo4 entry by benny",#Style,200,200,640,480,0,0,0,0)

pfd.PIXELFORMATDESCRIPTOR
hDC = GetDC_(hWnd)
pfd\nSize        = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion     = 1
pfd\dwFlags      = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\iLayerType   = #PFD_MAIN_PLANE
pfd\iPixelType   = #PFD_TYPE_RGBA
pfd\cColorBits   = 24  ;Colorbuffer
pfd\cDepthBits   = 32  ;Depthbuffer
pfd\cAlphaBits  = 1
pixformat = ChoosePixelFormat_(hDC, pfd)
SetPixelFormat_(hDC, pixformat, pfd)
hrc = wglCreateContext_(hDC)
wglMakeCurrent_(hDC, hrc)

SwapBuffers_(hDC)
glShadeModel_(#GL_SMOOTH)
glClearColor_(0.1, 0.1, 0.2, 0.1) ;Background color

glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
;gluPerspectivef_(50.0, 640/480, 0.1, 100.0)
gluPerspective(50.0, 640/480, 0.1, 100.0)
gluLookAt(0.0, -0.3, 0.2, 0.0, 0.0, -0.6, 0.0, 1.0, 0.0)
glMatrixMode_(#GL_MODELVIEW)

glEnable_(#GL_BLEND)
glDisable_(#GL_DEPTH_TEST)
glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE)

;##################################
;## Main Loop

;Repeat
!l_mainloop:
 
  If (PeekMessage_(msg.MSG, #Null, 0, 0, #PM_REMOVE))
      TranslateMessage_(msg)
      DispatchMessage_(msg)
  Else

  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
     
  glLoadIdentity_() ; Reset Plotter
  glTranslatef_(0.0, 0.0, -4.0) ; Move Plotter
  glRotatef_(65.0, -1.0, 0.0, 0.0)
  glRotatef_(rot.f, 0.0, 0.0, 1.0)
 
  glBegin_(#GL_LINES)
  ;Grid
    glColor4f_(0.8, 0.8, 1.0, 0.8)
    For x = -10 To 10 Step 2
      tx.f = x / 10
      glVertex3f_ (1.0, tx.f, 0.0)
      glVertex3f_ (-1.0, tx.f, 0.0)
    Next x
    For x = -10 To 10 Step 2
      tx.f = x / 10
      glVertex3f_ (tx.f, 1.0, 0.0)
      glVertex3f_ (tx.f, -1.0, 0.0)
    Next x
  glEnd_()
   
  ;Tree
  glBegin_(#GL_TRIANGLES)
    glColor4f_(0.0, 0.8, 0.0, 0.25)
    glVertex3f_(0.0, 0.0, 1.4)
    glVertex3f_(-0.8, 0.0 , 0.0)
    glVertex3f_(0.8, 0.0, 0.0)
     
    glVertex3f_(0.0, 0.0, 1.4)
    glVertex3f_(-0.5, -0.5, 0.0)
    glVertex3f_(0.5, 0.5, 0.0)
     
    glVertex3f_(0.0, 0.0, 1.4)
    glVertex3f_(-0.5, 0.5, 0.0)
    glVertex3f_(0.5, -0.5, 0.0)
  glEnd_()
   
   ;SnowFlake
  For z = 0 To #numFLAKES-1
    Flakes(z)\transZ - Flakes(z)\downZ
    If Flakes(z)\transZ <=0.0
      Flakes(z)\transZ = 0.0
      Flakes(z)\state = 1   ; dying
    EndIf
    If Flakes(z)\state = 1
      Flakes(z)\color - 0.01
      If Flakes(z)\color < 0.00
        InitSnow(z)
      EndIf
    EndIf
    glTranslatef_(Flakes(z)\transX, Flakes(z)\transY, Flakes(z)\transZ)
       glBegin_(#GL_LINES)
        glColor4f_(1.0, 1.0, 1.0, Flakes(z)\color)
        glVertex3f_(0.01, 0.01, 0.0)
        glVertex3f_(-0.01, -0.01, 0.0)
        glVertex3f_(0.01, -0.01, 0.0)
        glVertex3f_(-0.01, 0.01, 0.0)
        glVertex3f_(-0.01, 0.01, 0.0)
        glVertex3f_(0.01, -0.01, 0.0)
        glVertex3f_(0.0, 0.01, 0.01)
        glVertex3f_(0.0, -0.01, -0.01)
        glVertex3f_(-0.01, 0.0, -0.01)
        glVertex3f_(0.01, 0.0, 0.01)       
        glEnd_()
        glTranslatef_(Flakes(z)\transX*(-1), Flakes(z)\transY*(-1), Flakes(z)\transZ*(-1))
    Next z
   
    SwapBuffers_(hDC)
     
  rot.f + 0.6
  Delay(1)
EndIf

;Until finished = 10
!JMP l_mainloop

End


112
Hi.

I was experimenting with various soundsystems and their callback function for
syncing. Having this cool competition in mind I made this as an example.

Credits

Soundtrack static^rebels
Soundsystem fmod
code benny!

(Looking forward for the next compo ;-) )

113
Java,JS & Flash / [JA] Bouncing CircleScroll
« on: February 07, 2007 »
Here finally is the messy source code of my entry to the scroll competition.
See http://dbfinteractive.com/index.php?topic=1330.0;topicseen for the
original thread.

Code: [Select]
package anakata.modplay.example.applet;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import anakata.modplay.Meta;
import anakata.modplay.ThreadedPlayer;
import anakata.modplay.loader.ModuleLoader;
import anakata.modplay.module.Module;
import anakata.sound.output.JavaSoundOutput;
import anakata.sound.output.SoundDataFormat;


public class CircleScrollAna extends Applet {

   // Module Stuff
    public static final String INFO = Meta.PROJECT_NAME + " " + Meta.VERSION;

    public static final int BITS = 16;
    public static final int RATE = 44100;
    public static final int CHANNELS = 2;
    public static final boolean INTERPOLATE = true;
    public static final int BUFFERSIZE = 500;

    private Module module;
    private URL theUrl;
    private ThreadedPlayer tp;

    private String protocol;
    private String host;
    private int port;
    private List fileList = new ArrayList();
    private int nextModule = 0;

    private int lengthOfModule = 0;
   
// Applet Stuff
public int appHeight;
public int appWidth;
public Font appFont;


// Circlescroll Stuff
public CircleLetter[] letters = new CircleLetter[18];
public float fallFactor = 0.5f;
public float circleCenter_X;
public float circleCenter_Y;
public int border_Y;
public int circleRadius   = 100;
public int circleTextCount = 0;
public String circleText = "... this little bouncing circlescroller is my entry for the scroll comp at the wonderful "
+ "dbf+gvy demo code forum. Credits ... cool soundtrack by stargazer/cplx ... coding by benny! "
+ "ana-mp soundsystem by Torkjel Hongve ... greetings to shockwave, tracy, taj, jim, rbraz, "
+ "druid, rdc and all other forum guys who are keeping the oldschool demo spirit alive ... "
+ "... enjoy! ... benny!weltenkonstrukteur.de ... ... scroller restarts ... ... ";

    Image buffer;
    Graphics2D gBuffer;
   
    // CircleLetter InnerClass   
    public class CircleLetter {
    private String letter = "";
    private double radius;
    private int x,y;
    private boolean directionDown = true;
    private boolean directionLeft = true;
   
    public CircleLetter( double radius ) {
    this.radius = radius;
    }
   
    private void rotate( Graphics2D gBuffer ) {

    // Rotate and change chars
    radius = radius - 2 % 360;
   
    if ( (int)radius == 450 ) {
    letter = "" + circleText.charAt( circleTextCount );
    circleTextCount++;
    if ( circleTextCount == circleText.length() ) circleTextCount = 0;
    radius = 810;
    }
   
    // bounce up/down
    if ( directionDown ){
    fallFactor = fallFactor + 0.001f;
    circleCenter_Y = circleCenter_Y + fallFactor;
    if ( circleCenter_Y > border_Y ) {
    directionDown = false;
    }
    } else {
    fallFactor = fallFactor - 0.012f;
    if ( fallFactor < 0 ) {
    directionDown = true;
    }
    }
    // bounce left/right
    if ( directionLeft ){
    circleCenter_X = circleCenter_X + 0.1f;
    if ( circleCenter_X > 280 ) {
    directionLeft = false;
    }       
    } else {
    circleCenter_X = circleCenter_X - 0.1f;
    if ( circleCenter_X < 20 ) {
    directionLeft = true;
    }
    }
   
    // rotate
    x = (int)(circleRadius * Math.cos( radius * ( 2 * Math.PI / 360)) + circleCenter_X);
    y = (int)(circleRadius * Math.sin( radius * ( 2 * Math.PI / 360)) + circleCenter_Y);
   
    if ( y > appHeight ) y = appHeight;   
    if ( x > 288 ) x = 288;
    if ( x < 0 ) x = 0;
   
    gBuffer.drawString( letter, x, y);   
    }   
    }
   

   // Applet methods
   
    public void init() {

// App Stuff
appHeight    = this.getHeight();
appWidth    = this.getWidth();
appFont    = new Font( "Courier New", Font.BOLD, 20 );

// CircleScroll Stuff
circleCenter_X = this.getWidth() / 2;
circleCenter_Y = this.getHeight() / 2;
border_Y    = (int)(this.getHeight() * 0.95);

circleText = circleText.toUpperCase();

int start = 452;
for ( int i = 0; i < letters.length; i++ ) {
letters[i] = new CircleLetter( start );
start = start + 20;
}

// Music Stuff
        protocol = getParameter("protocol");
        host = getParameter("host");
        port = Integer.parseInt(getParameter("port"));
        StringTokenizer st = new StringTokenizer(getParameter("files"), ",");
        while (st.hasMoreTokens())
            fileList.add(st.nextToken());

        module = loadModule(nextModule++);
        // start the thread
        tp = createPlayer(module);
        lengthOfModule = tp.getModule().getNumberOfPositions();
        tp.start();       
       
}

    public void start() {
        tp.pause(false);
    }

    public void stop() {
        tp.pause(true);
    }

    public void destroy() {
        tp.stop();
    }

    /**
     * create a player thread for playing the
     * @param module
     * @return
     */
    private ThreadedPlayer createPlayer(Module module) {
        ThreadedPlayer player = new ThreadedPlayer();
        try {
            player.init(
                new JavaSoundOutput(new SoundDataFormat(BITS, RATE, CHANNELS), BUFFERSIZE),
                INTERPOLATE);
            player.load(module);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        player.pause(true);
        return player;
    }

    /**
     * load the <code>nextModule</code>'th file in the file list.
     * @param nextModule
     * @return
     */
    private Module loadModule(int nextModule) {
        int mc = fileList.size();
       
        while (nextModule <= 0) nextModule += mc;
        try {
            theUrl = new URL(protocol, host, port, (String)fileList.get((nextModule + mc) % mc));
            return ModuleLoader.getModuleLoader(theUrl).getModule();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


public void paint(Graphics g) {

        // Double-Buffering
        if (buffer==null) {
            buffer=createImage(this.getSize().width, this.getSize().height);
            gBuffer=(Graphics2D)buffer.getGraphics();
        }
        gBuffer.setBackground( new Color( 120, 120, 250 ));
        gBuffer.setColor( Color.WHITE );
        gBuffer.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,
        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        gBuffer.clearRect( 0,0,this.getSize().width, this.getSize().height);

        // Antialiasing
        gBuffer.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
       
        gBuffer.setFont( appFont );
       
        for ( int i=0; i < letters.length; i++ ) {
        letters[i].rotate( gBuffer );
        }
        g.drawImage (buffer, 0, 0, this);       
       
        // Delay
        try {Thread.sleep(10);}
        catch (InterruptedException e) {}                       

        // Loop Module
        if ( lengthOfModule == tp.getPosition() ) {
        tp.setPosition( 0 );
        tp.start();
        }
       
        repaint();
}

    public void update(Graphics g) {
    paint(g);
    }

}

114
Here is my entry to the scrollcompetition called :

Bouncing CircleScroll (click on the link to view it online)
http://www.weltenkonstrukteur.de/works/varworks/circleScroll.htm

First time I code a java applet - hope it runs fine on most of your
computers. You should have of course a java runtime installed
(I recommend jre1.5 or higher...). Successfully tested in Firefox2.0
and IExplore7.0.


Creditz

Music by stargazer/cplx
Ana-Mp soundsystem by Torkjel Hongve
Coding by benny!


Note:
Sources will be released after reformatting a bit in the
"Java, Flash + Browser.. " forum.

115
Java,JS & Flash / [JS] Human Typer
« on: January 31, 2007 »
Hi,

here is a little telex / typer text effect written in Javascript. Its a normal
telex / typer effect - but additionally I added some 'human touch' to it - so the
typing speed varies from character to character and the typer 'makes' typing
mistakes from time to time.

Here is a small example online :

http://www.weltenkonstrukteur.de/ext/HumanTyper.htm

Source code:

Code: [Select]
/**
 * - Human Typer -
 *
 * @author benny!weltenkonstrukteur.de
 * @license LGPL ( see : http://www.gnu.org/licenses/lgpl.html )
 * @version 1.0
 * @projectDescription
 * A type / telex fx in javascript with a 'human touch'.
 *
 *  Disclaimer: I am providing this source code "as-is," without accepting any
 *             responsibility for the effects it may have on your computer,
 *              network, or livelihood. If you decide to use portions of my
 *              code in your project or product, I would be very pleased to be
 *              attributed.  More importantly, please e-mail me to tell me
 *              about it!  Do not charge money for this source code, as it is
 *              intended to be freely distributed.  Do not remove this header
 *              text from the source file, and do not change the version string.
 */


/**
 * @param divId [String]
 * The id of the content innerHtml to output.
 * @param newDelay [Number]
 * The maximum delay of the typer.
 * @param newCorrenctness [Number]
 * The Correctness specifies how much typing mistakes the typer
 * makes. The higher the less typing mistakes are made.
 *
 */

function HT_Init( divId, newDelay, newCorrectness ) {
document.getElementById(divId).style.visibility = "hidden";
// Getting innerHtml of specified div
var div = document.getElementById( divId );
message = div.innerHTML;
document.getElementById(divId).innerHTML = "";
document.getElementById(divId).style.visibility = "visible";
delay = newDelay;
correctNess = newCorrectness;

// Globals - change them if you want !
cursor = "_"; // Cursor char

// System variables
curState= 0;
errMsg = "";
divTelex= document.getElementById( divId );
counter = -1;
errCount= 0;
errWay = 0;
tagFlag = 0;
setTimeout( 'HT_Write();', 100 );
}


function HT_Write() {

if ( errWay == 0 && counter > 3 && (Math.floor ( Math.random() * correctNess ) == 0) ) {
errCount = Math.floor( Math.random() * 2 ) + 2;
errWay = 1;
}

if ( errWay == 1 ) {
errMsg = errMsg +  String.fromCharCode( Math.floor ( Math.random() * 89) + 33 );
divTelex.innerHTML = message.substr(0, counter + 1 ) + errMsg + HT_GetCursor();
if ( errCount == errMsg.length ) {
errWay = 2;
}
setTimeout ( 'HT_Write();', Math.floor( Math.random() * 250 ) + delay );
return;
}
else if ( errWay == 2 ) {
errCount--;
divTelex.innerHTML = message.substr( 0, counter + 1 ) + errMsg.substr( 0, errCount ) + HT_GetCursor();
if ( errCount == 0 ) {
errWay = 0;
errMsg = "";
}
setTimeout( 'HT_Write();', Math.floor( Math.random() * 250 ) + delay );
return;
} else {
if ( message.substring( counter, counter + 1) != '<'  ){
divTelex.innerHTML = message.substr ( 0, counter + 1 ) + HT_GetCursor();
} else {
while ( message.substring( counter, counter + 1) != '>'  ) {
//divTelex.innerHTML = message.substr ( 0, counter + 1 );
var tagStuff = message.substr ( 0, counter + 1 );
counter ++;
}
divTelex.innerHTML = tagStuff;
}
counter++;
if ( counter < message.length ) {
setTimeout( 'HT_Write();', Math.floor( Math.random() * delay ) );
return;
} else {
divTelex.innerHTML = message.substr ( 0, counter + 1 );
}
}
}

function HT_GetCursor() {
if ( curState == 0 ) {
curState = 1;
return " ";
} else {
curState = 0;
return "_";
}
}

Source + Example also added to this thread.

Successfully tested on :

- Mozilla Firefox 2.0
- Internet Explorer 7.0

116
Purebasic / PureBasic NeHe Lessons
« on: January 23, 2007 »
Hi all,

just thought it would be a good idea to post links to some translated
NeHe lessons which where done by the purebasic community on
the official board as they are not listed on the official NeHe Site yet.

Lesson 01

Lesson 02

Lesson 03

Lesson 04

Lesson 05

Lesson 06

Lesson 07

Lesson 08

Lesson 09

Lesson 10

Lesson 11

Lesson 12

Lesson 13

Lesson 14

Lesson 15

Lesson 16

Lesson 17

Lesson 18

Lesson 19

Lesson 20

Lesson 21


117
General chat / Famous cracker- / demogroup slogan
« on: January 16, 2007 »
Hi all.

refering to this cool topic I wanna ask you which slogans you still have
in mind when thinking about cracker- and/or demogroups.

I'll start off with the following :

Infect! : "crush down inferiors."

Sanity: "demo or die!"

Scoopex: "generations ahead"

Quartex: "there can only be one"



... looking forward to see what you still remember  ;)

118
Cobra / Timeline / Future Plans
« on: January 12, 2007 »
Hi all,

I just downloaded the demo version of cobra and run the examples. Have to say that I am really
impressed. Now I wonder if there are any concrete timetables or plans about upcoming releases
of cobra. Heard that a special 3D module is planned ? Any more details about that ? Is Cobra
primarily designed for multimedia applications ?

Furthermore I really do like the clean structure of the program and the IDE with the treelist at
the right. This really gives you a good overview of your code as far as I can say from now.

Looking forward to see this languages growing ...

119
General chat / Downtimes
« on: January 12, 2007 »
Hi.

In the last two days it is impossible to reach dbfinteractive.com from time
to time. Is it just me ( local problem ) or has anyone else outside germany the
same problem ???

It just takes two minutes or so - then I can "connect" again. Very strange ...

120
Purebasic / Resource sites
« on: January 11, 2007 »
Hi,

I'll use this thread to post purebasic related useful links. I do not post them in the
general useful links sections because the urls posted here are purebasic related
only!.

If you have any more interesting links - feel free to add them !



Links

- Official site http://www.purebasic.com
( Official site where you can download latest releases with your
  personal account (paid) )


- PureArea.net http://www.purearea.net
( Excellent resource sites for 3rd party libs, code snippets et cetera )

- PureWiki http://www.purearea.net/pb/english/purewiki/index.php/Main_Page
( Wiki for purebasic. Also hosted on purearea.net )

- PB Showcase http://www.purearea.net/pb/showcase/index.php
( Showcase of some fine purebasic releases by the community )

- Official PB forum http://www.purebasic.fr/english/
( This is the official purebasic forum for all versions of pb )

... more to come  ;)

Pages: 1 2 3 4 5 [6] 7