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 - Paul

Pages: [1] 2
1
General chat / Fun little game
« on: July 11, 2009 »
Found a game called my brute, where your brute fights other brutes. Totally pointless, but interesting anyway. Heres a link to sign up (and give me an extra experience point :)). have fun

http://paul1200.mybrute.com

2
Blitz / Pathfinding problem
« on: December 29, 2008 »
HI!
I'm making a pathfinding code. The problem is that it gets slower and slower the more I use it. I've isolated the slowdown to these lines of code, but I find nothing wrong with them. It gets so bad that it only manages 2000 iterations a second.
Edit: Fs() is an array
Code: [Select]
Const t0 =2^0
Const t1 =2^1
Const t2 =2^2
Const t3 =2^3
...
Const t20=2^20

Dim Fs(2^20-1)

Type Square
Field x,y
Field F
Field G
Field H
Field n
Field n2
Field Previous.Square
End Type


tmp=MilliSecs()
For o.Square=Each Square
p=t19+((o\F And t18) Shr 17-1) Shl 18
Fs(p)=0
p=p  +((o\F And t17) Shr 16-1) Shl 17
Fs(p)=0
p=p  +((o\F And t16) Shr 15-1) Shl 16
Fs(p)=0
p=p  +((o\F And t15) Shr 14-1) Shl 15
Fs(p)=0
p=p  +((o\F And t14) Shr 13-1) Shl 14
Fs(p)=0
p=p  +((o\F And t13) Shr 12-1) Shl 13
Fs(p)=0
p=p  +((o\F And t12) Shr 11-1) Shl 12
Fs(p)=0
p=p  +((o\F And t11) Shr 10-1) Shl 11
Fs(p)=0
p=p  +((o\F And t10) Shr 9 -1) Shl 10
Fs(p)=0
p=p  +((o\F And t9 ) Shr 8 -1) Shl 9
Fs(p)=0
p=p  +((o\F And t8 ) Shr 7 -1) Shl 8
Fs(p)=0
p=p  +((o\F And t7 ) Shr 6 -1) Shl 7
Fs(p)=0
p=p  +((o\F And t6 ) Shr 5 -1) Shl 6
Fs(p)=0
p=p  +((o\F And t5 ) Shr 4 -1) Shl 5
Fs(p)=0
p=p  +((o\F And t4 ) Shr 3 -1) Shl 4
Fs(p)=0
p=p  +((o\F And t3 ) Shr 2 -1) Shl 3
Fs(p)=0
p=p  +((o\F And t2 ) Shr 1 -1) Shl 2
Fs(p)=0
p=p  +((o\F And t1 )       -1) Shl 1
Fs(p)=0
p=p  +((o\F And t0 ) Shl 1 -1)
Fs(p)=0
Next
clean=(MilliSecs()-tmp)

3
Challenges & Competitions / [PROCEDURAL] Flame
« on: May 15, 2008 »
Hi!
Here is an effect that from the beginning was supposed to be a leaf, but i got off track and it changed allot.
It's a little slow, but its well worth it :)
Press space to render a new image.
http://dbfinteractive.com/index.php?action=tpmod;dl=get68

Made another version that feels more alive.
http://www.snapdrive.net/qs/197aac560f14

4
Useful links / Some really hard games
« on: January 20, 2008 »
If you like games that are super hard but addicting then have a look at this site.

http://messhof.com/

Edit: just want to warn you that these games are stupidly annoying and difficult.

5
C / C++ /C# / G15 Keyboard
« on: December 26, 2007 »
Hi
I got a Logitech G15 keyboard for Christmas and now I'm trying to program it. I'ts got a monochrome graphical LCD screen.
I've managed to get a simple program going in c++, but since i prefer Blitz3D I would like to create a dll with some simple functions.


This works
Code: [Select]
lgLcdOpenContext InnitLCD(LPCSTR name)
{
DWORD res;

    //// initialize the library
    res=lgLcdInit();//res
    HandleError(res, _T("lgLcdInit"));
   
    //// connect to LCDMon
    // set up connection context
    lgLcdConnectContext connectContext;
    ZeroMemory(&connectContext, sizeof(connectContext));
    connectContext.appFriendlyName = _T(name);//"simple sample");
    connectContext.isAutostartable = false;
    connectContext.isPersistent = false;
    // we don't have a configuration screen
    connectContext.onConfigure.configCallback = NULL;
    connectContext.onConfigure.configContext = NULL;
    // the "connection" member will be returned upon return
    connectContext.connection = LGLCD_INVALID_CONNECTION;
    // and connect
    res=lgLcdConnect(&connectContext);//RES
    HandleError(res, _T("lgLcdConnect"));

    // now we are connected (and have a connection handle returned),
    // let's enumerate an LCD (the first one, index = 0)
    lgLcdDeviceDesc deviceDescription;
    res=lgLcdEnumerate(connectContext.connection, 0, &deviceDescription);//res
    HandleError(res, _T("lgLcdEnumerate"));

    // at this point, we have an LCD
    //_tprintf(_T("Found an LCD with %dx%d pixels, %d bits per pixel and %d soft buttons\n"),
    //    deviceDescription.Width, deviceDescription.Height, deviceDescription.Bpp,
    //    deviceDescription.NumSoftButtons);

// open it
    lgLcdOpenContext openContext;
    ZeroMemory(&openContext, sizeof(openContext));
    openContext.connection = connectContext.connection;
    openContext.index = 0;
    // we have no softbutton notification callback
    openContext.onSoftbuttonsChanged.softbuttonsChangedCallback = NULL;
    openContext.onSoftbuttonsChanged.softbuttonsChangedContext = NULL;
    // the "device" member will be returned upon return
    openContext.device = LGLCD_INVALID_DEVICE;
    res=lgLcdOpen(&openContext);//res
    HandleError(res, _T("lgLcdEnumerate"));


return openContext;
}
But since Blitz cant get the returned class i need to send it to my function, and let c++ edit the content
This code here doesn't work though
Code: [Select]
void InnitLCD(LPCSTR name,lgLcdOpenContext openContext)
{
DWORD res;

    //// initialize the library
    res=lgLcdInit();//res
    HandleError(res, _T("lgLcdInit"));
   
    //// connect to LCDMon
    // set up connection context
    lgLcdConnectContext connectContext;
    ZeroMemory(&connectContext, sizeof(connectContext));
    connectContext.appFriendlyName = _T(name);//"simple sample");
    connectContext.isAutostartable = TRUE;
    connectContext.isPersistent = TRUE;
    // we don't have a configuration screen
    connectContext.onConfigure.configCallback = NULL;
    connectContext.onConfigure.configContext = NULL;
    // the "connection" member will be returned upon return
    connectContext.connection = LGLCD_INVALID_CONNECTION;
    // and connect
    res=lgLcdConnect(&connectContext);//RES
    HandleError(res, _T("lgLcdConnect"));

    // now we are connected (and have a connection handle returned),
    // let's enumerate an LCD (the first one, index = 0)
    lgLcdDeviceDesc deviceDescription;
    res=lgLcdEnumerate(connectContext.connection, 0, &deviceDescription);//res
    HandleError(res, _T("lgLcdEnumerate"));

    // at this point, we have an LCD
    //_tprintf(_T("Found an LCD with %dx%d pixels, %d bits per pixel and %d soft buttons\n"),
    //    deviceDescription.Width, deviceDescription.Height, deviceDescription.Bpp,
    //    deviceDescription.NumSoftButtons);

// open it
   // lgLcdOpenContext openContext;
    ZeroMemory(&openContext, sizeof(openContext));
    openContext.connection = connectContext.connection;
    openContext.index = 0;
    // we have no softbutton notification callback
    openContext.onSoftbuttonsChanged.softbuttonsChangedCallback = NULL;
    openContext.onSoftbuttonsChanged.softbuttonsChangedContext = NULL;
    // the "device" member will be returned upon return
    openContext.device = LGLCD_INVALID_DEVICE;
    res=lgLcdOpen(&openContext);//res
    HandleError(res, _T("lgLcdEnumerate"));


//return openContext;
}
So how would i edit the fisrts peice of code so i can call it like this:
Code: [Select]
lgLcdOpenContext openContext;
memset(&openContext,0,sizeof(openContext));
InnitLCD(_T("NAME"),openContext);

6
General coding questions / Pixel perfect collisions
« on: December 03, 2007 »
HI!
I'm working on an image collision routine. Right now I'm checking all the pixels that overlap the collision rectangles(hope you understand what i mean :)).
Right now it's about 50x slower than the built in one in blitz. Some ideas i have to speed it up are, at least one is to.
divide the image up into 4 smaller squares, repeatedly until i get down to the pixel level.
If it doesn't sound clear the attached image below probably wont help :P
Any other Ideas on how to make a faster image collision checker are welcome.


The code (in blitz, i start here but will rewrite it i c# when it's done).

Code: [Select]
Const gx=1024
Const gy=768
;Const debug_c=1


Graphics gx,gy,32,2
SetBuffer BackBuffer()


Local image1 = loadimage2("",-16777216);black
Local image2 = loadimage2("",-16777216);black


HidePointer()


Local mx
Local my
Local mz

While Not KeyHit(1)

mx=MouseX()
my=MouseY()
mz=MouseZ()

drawimage2(image1,20,20,Abs(mz) Mod 2)
drawimage2(image2,mx,my,Abs(mz) Mod 2)
If ImagesCollide2(image1,20,20,image2,mx,my) Then Text 0,0,"!!!!!!!!!!!!!"




Flip
Cls

Wend

Function drawimage2(image,x,y,debug=0)

If debug
Local i=0
LockBuffer BackBuffer()
Local iw=PeekShort(image,6)

For x1=0 To PeekShort(image,4)-1
For y1=0 To PeekShort(image,6)-1
i=x1*iw+y1
If Not y1+y=>gy Or y1+y<0 Or x1+x=>gx Or x1+x<0
If PeekByte(image,i/8+8) And (1 Shl (i Mod 8))
WritePixelFast(x+x1,y+Y1,255)
EndIf

EndIf
i=i+1
Next
Next
UnlockBuffer BackBuffer()
Else
DrawImage(PeekInt(image,0),x,y)
EndIf
End Function

Function loadimage2(Image_f$,Mask)
Local Image=LoadImage(Image_f$)
Local Iw=ImageWidth(Image)
Local Ih=ImageHeight(Image)

Local bank=CreateBank(((Ih*Iw) Shr 3)+9)
PokeInt(bank,0,Image)
PokeShort(bank,4,Iw)
PokeShort(bank,6,Ih)
;DebugLog Iw+","+Ih

Local i,x,y,byte=0
Local buffer=ImageBuffer(Image)
LockBuffer buffer
;Mask=ReadPixelFast(0,0,buffer)
For i=0 To (Iw*Ih)-1
y=i-(i/Ih)*Ih
x=i/Ih
If ReadPixelFast(x,y,buffer)<>Mask
byte=byte+(1 Shl (i Mod 8))
EndIf
If i Mod 8=7
PokeByte(bank,i/8+8,byte)
byte=0
EndIf
Next
UnlockBuffer buffer

Return bank
End Function

Function MaskImage2(image,mask)
iw=PeekShort(image,4)
ih=PeekShort(image,6)

Local buffer=ImageBuffer(PeekInt(image,0))
LockBuffer buffer
For i=0 To iw*ih-1
y=i-(i/Ih)*Ih
x=i/Ih
If ReadPixelFast(x,y,buffer)<>mask
byte=byte+(1 Shl (i Mod 8))
EndIf
If i Mod 8=7
PokeByte(image,i/8+8,byte)
byte=0
EndIf
Next
UnlockBuffer buffer

End Function

Function ImagesCollide2(image1,x1,y1,image2,x2,y2)
Local sx1=PeekShort(image1,4)
Local sy1=PeekShort(image1,6)

Local sx2=PeekShort(image2,4)
Local sy2=PeekShort(image2,6)

Local top
Local bottom
Local Left
Local Right


If x1>x2
Left=x1
Else
Left=x2
EndIf
If y1>y2
top=y1
Else
top=y2
EndIf

If y1+sy1<y2+sy2
bottom=y1+sy1
Else
bottom=y2+sy2
EndIf
If x1+sx1<x2+sx2
Right=x1+sx1
Else
Right=x2+sx2
EndIf


t1=top-y1
t2=top-y2

For x=Left To Right-1
i1=(x-x1)*sy1+t1
i2=(x-x2)*sy2+t2
f1=i1 Mod 8
f2=i2 Mod 8
For y=top To bottom-1
;n1%=PeekByte(image1,i1 Shr 3+8) And 1 Shl f1
;n2%=PeekByte(image2,i2 Shr 3+8) And 1 Shl f2
;If n1>0 And n2>0 Then Return 1
;If debug_c=0
;I know reading the byte for every pixel is lame, but I hopefully wont have that problem in c#
If (PeekByte(image1,i1 Shr 3+8) And 1 Shl f1)>0 And (PeekByte(image2,i2 Shr 3+8) And 1 Shl f2)>0 Then Return 1
;Else
; If (PeekByte(image1,i1 Shr 3+8) And 1 Shl f1)>0 And (PeekByte(image2,i2 Shr 3+8) And 1 Shl f2)>0 Then Plot x,y
;EndIf
i1=i1+1
i2=i2+1
f1=f1+1
f2=f2+1
If f1>7 Then f1=0
If f2>7 Then f2=0
Next
Next
Return 0
End Function





[code]
[/code]

7
Blitz / Magnifyingglass effect
« on: October 06, 2007 »
Hi
Here's a lens effect that i made, could probably get it more optimised, but i don't know how :(
Used Mike_g's colourblend, hope thats ok.

Use the mousewheel or up and down to change the magnification

Code: [Select]
Const gx=1024,gy=768
Graphics gx,gy,32,1
SetBuffer BackBuffer()


Dim buffer(gx,gy)

Local image=LoadImage("C:\Users\paul\Desktop\Paul\mekis0fx200g1a.jpg")
If image=0 Then RuntimeError("Image failed to load")

If ImageWidth (image)>gx Then BX=gx-1 Else bx=ImageWidth (image)-1;check to see that we don't load an image thats bigger than our aray(x)
If ImageHeight(image)>gy Then By=gy-1 Else by=ImageHeight(image)-1;-----------------------------------!!------------------------------(y)


LockBuffer ImageBuffer(image);copy image inteo an array
For x=0 To bx
For y=0 To by
buffer(x,y)=ReadPixelFast(x,y,ImageBuffer(image))
Next
Next
UnlockBuffer ImageBuffer(image)


Global r#=50
While Not KeyHit(1)
DrawImage(image,0,0)


r#=r#+KeyDown(208)-KeyDown(200)+MouseZSpeed()
If KeyHit(203)+KeyHit(205) Then r#=60

LockBuffer
magnify(200,MouseX(),MouseY())
UnlockBuffer

Text 0,20,r#-50
;-------------------------------------------------------------------------
frame=frame+1;FPS timer
If MilliSecs()>time
time=MilliSecs()+1000
frames=frame
frame=0
EndIf
Text 0,0,"FPS:"+frames
;-------------------------------------------------------------------------
Flip 0
Cls
Wend


Function magnify(radius,cx,cy)
Local x,y,half_row_width,tx,ty,ang#,dist#
Local tx2#,ty2#

For y=-radius To radius
half_row_width=Sqr(radius^2-y^2)
For x=-half_row_width To half_row_width
tx=(cx+x) ;Get the current x drawing position
ty=(cy+y) ;Get the current y drawing position

ang#=ATan2(x,y) ;get the angle betwen the centre and the current pixel being drawn
;dist#=Sin(Sqr(x*x+y*y)/0.5)*(100)
dist#=(x*x+y*y)/500+Sqr(x*x+y*y)*r#/100 ;Get the distance ----------------------!!-------------------------

If tx>0 And ty>0 And tx<gx And ty<gy ;make sure we arent drawing outside the screen
tx2#=cx+Sin(ang)*dist ;precalcute the x
ty2#=cy+Cos(ang)*dist ; and y position
If tx2#>0 And tx2#<gx And ty2#>0 And ty2#<gy ; make sure we arent readin from outside the screen
x1=Floor(tx2#) ;Get the low  x cordinate
x2=Ceil (tx2#) ;Get the high x cordinate
y1=Floor(ty2#) ;Get the low  y cordinate
y2=Ceil (ty2#) ;Get the high y cordinate
col1=ColourBlend(buffer(x2,y1),buffer(x1,y1),(tx2#-x1)*256) ; blend the two colors with the difference betwen their two positions
col2=ColourBlend(buffer(x2,y2),buffer(x1,y2),(tx2#-x1)*256) ; in the x direction

col1=ColourBlend(col2,col1,(ty2#-y1)*256) ; and the y dirrection
WritePixelFast(tx,ty,col1) ; then draw it all to the screen
Else
WritePixelFast(tx,ty,0) ;if we try to draw to the screen but try to read from outside the screen then draw a black pixel
EndIf
EndIf
Next
Next

End Function


Function ColourBlend( rgb_1, rgb_2, alpha_1 );Mike_g's colour blend routine
alpha_2 = 256 - alpha_1

rb_1 = ((rgb_1 And $00FF00FF) * alpha_1) And $FF00FF00
g_1  = ((rgb_1 And $0000FF00) * alpha_1) And $00FF0000
rb_2 = ((rgb_2 And $00FF00FF) * alpha_2) And $FF00FF00
g_2  = ((rgb_2 And $0000FF00) * alpha_2) And $00FF0000

rb_1 = rb_1 + rb_2
g_1  = g_1 + g_2

Return (rb_1 Or g_1) Sar 8
End Function


8
C / C++ /C# / c++ Data?
« on: September 21, 2007 »
I'm wondering how to include data in my c++ exe?

In blitz i would use the Data statement, for example:
Data 1,2,3
Data 2,4,6
Data 4,5,1
and the use
'Read ' to get the information back.
could anyone show me a quick example of how i would do this pealse :)

9
C / C++ /C# / Visual studio 2008 + platform sdk
« on: September 17, 2007 »
Hi
I'm wondering if platform sdk installs automaticly with visual studio 2008 beta 2?

This compile and i think this means i've got the sdk:
Code: [Select]
// My first win32.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <IOSTREAM>
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{

std::cout << "Hello World";

MessageBox(0,L"Hej",L"En ruta",0);

return 0;
}



10
General chat / Gigabytes for free?
« on: August 15, 2007 »
Read about this in PcGamer i think but i haven't dared try it.
http://www.theinquirer.org/default.aspx?article=14597

It might trash you're drive or give you a few free gigabytes, even hundreds according to this site.

11
Blitz / Red/Cyan 3D[BB3D]
« on: July 09, 2007 »
I've always been wanting to make a game in RED/CYAN and here is the first step...

What do you think, could i make it better, actually i haven't done any research, just done what felt good:)

Code: [Select]



Graphics3D 1024,768
SetBuffer BackBuffer()

Global camera2d=CreateCamera()
CameraRange(camera2d,0.149,1000)
Global plane=CreatePlane(1,camera2d);make a something pickable
PositionEntity plane,0,0,.15;and stick it in the correct place
RotateEntity plane,-90,0,0
EntityAlpha plane,0
EntityPickMode plane,2

Global Rsprite=CreateSprite()
Global Bsprite=CreateSprite()
EntityColor Bsprite,255,0,0
EntityColor Rsprite,0,255,255
sizesprite(Rsprite,1024,1024)
sizesprite(Bsprite,1024,1024)
Global Rtex=CreateTexture(1024,1024):EntityTexture(Rsprite,Rtex)
Global Btex=CreateTexture(1024,1024):EntityTexture(Bsprite,Btex)

EntityAlpha Bsprite,1
EntityBlend Bsprite,3

EntityOrder Rsprite,-1
EntityOrder Bsprite,-2

Global FPoint=CreatePivot()

light=CreateLight()
PositionEntity(light,-100,-100,-100)


Dim cubes(4)

For i=0 To 1000
cube=CreateCube()
PositionEntity(cube,Rnd(10,200),Rnd(10,200),Rnd(10,200))
RotateEntity(cube,Rnd(0,359),Rnd(0,359),Rnd(0,359))
;EntityColor cube,Rand(255),Rand(255),Rand(255)
Next

For i=0 To 4
cubes(i)=CreateCube()
PositionEntity(cubes(i),-i*10,-i*10,-i*10)
ScaleEntity(cubes(i),Rnd(1,10),Rnd(1,10),Rnd(1,10))

Next

While Not KeyHit(1)
For i=0 To 4
TurnEntity(cubes(i),(i Mod 4)*4,(i Mod 3)*3 ,(i Mod 2)*4)
Next
mouselook(camera2d)

render3d(.3,30)

Flip
Cls
Wend


Function mouselook(cam)


TurnEntity(cam,300-MouseY(),400-MouseX(),0)
MoveMouse(400,300)


If KeyDown(200) Then MoveEntity(cam,0,0,1)
If KeyDown(208) Then MoveEntity(cam,0,0,-1)
MoveEntity(cam,KeyDown(205)-KeyDown(203),0,KeyDown(200)-KeyDown(208))
TurnEntity(cam,0,0,-EntityRoll(cam))

End Function


Function render3d(dist#=0.5,focusRange#=50)
HideEntity(Rsprite)
HideEntity(Bsprite)
rt=MilliSecs()

Local spitch#=EntityPitch#(camera2d)
Local syaw#=EntityYaw#(camera2d)
Local sroll#=EntityRoll#(camera2d)

MoveEntity(camera2d,0,0,focusRange#)
Local x#=EntityX(camera2d)
Local y#=EntityY(camera2d)
Local z#=EntityZ(camera2d)
PositionEntity(FPoint,x,y,z)
RotateEntity(FPoint,spitch,syaw,sroll)
MoveEntity(FPoint,0,0,dist#/2)


MoveEntity(camera2d,dist/2,0,-focusRange#)
PointEntity(camera2d,FPoint)
RenderWorld()
CopyRect 0,0,1024,768,0,0,BackBuffer(),TextureBuffer(Rtex)
RotateEntity(camera2d,spitch,syaw,sroll)

MoveEntity(FPoint,0,0,-dist#)
MoveEntity(camera2d,-dist,0,0)
PointEntity(camera2d,FPoint)
RenderWorld()
CopyRect 0,0,1024,768,0,0,BackBuffer(),TextureBuffer(Btex)
MoveEntity(camera2d,dist/2,0,0)
RotateEntity(camera2d,spitch,syaw,sroll)

ShowEntity(Rsprite)
ShowEntity(Bsprite)
positionsprite(Rsprite,512,512)
positionsprite(Bsprite,512,512)
RenderWorld()
Return MilliSecs()-rt
End Function


;---------------
Function positionsprite(sprite,x,y)
Local picked=CameraPick(camera2d,x,y)
If picked<>0
PositionEntity(sprite,PickedX(),PickedY(),PickedZ())
EndIf
End Function

Function sizesprite(sprite,sizex#,sizey#)
ScaleSprite sprite,sizex#/5330,sizey#/5330
End Function


Edit: had my glasses on the wrong way round :P, now it might work for somebody else too..
got rid of the colours as jim suggested and i think it runns great. The only bottleneck is the copyrect  which takes about 20*2 ms.

12
Freebasic / Freebasic opengl tutorials?
« on: July 04, 2007 »
Hi
I'm looking for opengl tutorials for freebasic and I'm wondering if you got any suggestions?
saw the nehe ones, but they seem to need gl\glaux.bi for something and they're not fr freebasic which makes everything a little more complicated.

thx
//Paul

13
General chat / google street view
« on: May 30, 2007 »
http://maps.google.com/ and press the street view button at the top of the flash window, then find a blue street and double click on it.
http://preview.local.live.com/
A similar thing by microsoft.

14
Blitz / keyboard mapping[BB2D]
« on: April 14, 2007 »
Local i,tmp$;Define out varibles
This is a program to get the scancode and the name of the key pressed, but if i Press a special key like home or ctrl then it doesn't show up correctly. Is there a better way of doing this?
 
Code: [Select]
;;;;;;;main loop checkuing for keyhit escape
While Not KeyHit(1)

For i=0 To 256  ;repeat threw all the keys  (and maybe to far )
If KeyHit(i)  ;find what the keys scancode
tmp$=Chr$(GetKey());get the name of the key
Print i+","+tmp$ ;Print it all on the screen
EndIf
Next

Wend


15
General chat / Strange noise
« on: April 13, 2007 »
i've noticed that running programs with extremly high fps makes a slight noise, should it do this, is something wrong?

Running this
Code: [Select]
Graphics 800,600

While Not KeyHit(1)

Wend
makes slight humming noise and that scares me a little bit ;)

16
Blitz / Blitz coding[BB2D]
« on: April 11, 2007 »
Found this site today and did the first exercise

http://www.binarysurge.com/blitzhack/page.php?p=exercises

Here's my code, don't look at it if you're going to do the exercises.

Code: [Select]



















Graphics 800,600
SetBuffer BackBuffer()

Type enemy
Field x#,y#
Field xdir#,ydir#
Field let,col
End Type
timer=CreateTimer(70)
Global score,miss,mul#=1
While Not KeyHit(1)
If MilliSecs()-time>1000 Then newlet():time=MilliSecs()
Color 255,255,255
Text 0,0,"score: "+(level*100+score)
Text 0,20,"Misses:"+miss+"/"+5
If score=>100
score=0
level=level+1
mul#=mul#+0.1
Text 400,300,"Level "+(level+1),1,1
Flip
Delay 1000
miss=0
EndIf
If miss=>5 Then End
tmp$=Lower$(Chr$(GetKey()))
printlet(tmp$)
WaitTimer(timer)
Flip
Cls
Wend

Function printlet(tmp$)
oscore=score
For a.enemy= Each enemy
a\x=a\x+a\xdir#*mul
a\y=a\y+a\ydir#*mul
let=a\let
If let<65 Then let=let-7
Color a\col Shr 16 And $ff,a\col Shr 8 And $ff,a\col And $ff
Oval a\x-5,a\y-5,20,20
Color 0,0,0
Text a\x,a\y,Chr$(let)
If a\x>800 Or a\y>600 Or a\x<0
miss=miss+1
Delete a
Else
If tmp$=Lower$(Chr$(let)) Then score=score+10:Delete a

EndIf
Next

If Asc(tmp$)<>0 And score=oscore Then miss=miss+1
End Function
Function newlet()
a.enemy=New enemy
a\x#=Rnd(200,400)
a\xdir#=Rnd(-2,2)
a\ydir#=Rnd(0,2)
a\let=randletter()
a\col=Rnd(100,255) Shl 16 Or Rnd(100,255) Shl 8 Or Rnd(100,255)
End Function
Function randletter()
tmp=Rnd(55,90)
Return tmp
End Function

17
Blitz / Achtung[BB2D]
« on: April 08, 2007 »
Hi

This is a game I played somewhere and liked, so i made  remake of it in blitz.
The bots are stupid

the controls are

P1: left arrow ,right arrow
P2: left ctrl ,left alt
P3: Q,W
P4: numpad 2,3
P5: O,P

This is just a simple game that probably contains very many bugs so don't be to hard.

http://dbfinteractive.com/index.php?action=tpmod;dl=item52


The bots are stupid :)

18
General chat / HL2 episode 2
« on: April 05, 2007 »
Team Fortress 2 and Portal, what do you think of it?

Heres a link to the portal site:

http://www.aperturescience.com/

19
Blitz / Microphone[BB2D]
« on: April 04, 2007 »
Hi
I'm wondering how to use the microphons with blitzbasic 3d. If this isnt posible then I'm ready to do it with freebasic.

I'm thinking of using Bass but the functions don't seem to be available with the version of blitzbass that i've got.

20
Freebasic / Constructor?
« on: March 23, 2007 »
How do i declare a constructor?
this is my try and it doesn't work :(

Code: [Select]

type thing
    Declare Constructor()
   
end type

constructor thing
   
end constructor


Pages: [1] 2