Menu

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.

Show posts Menu

Messages - Kitty Hello

#10396
Ganz wichtig dabei ist dabei immer die Version von GPC und Editor:
Bei mir hier:
Editor: 2.50619
GPC - GLBasic Precompiler V.2005.17

Da geht eigentlich alles...
#10397
Did you read the tutorial's "adnvanced" section?

You can do this:
Code (glbasic) Select
DIM a[5]
a[4] = 12
DIM a[2][9]
a[1][7] = 2
DIM a[0] // free memory
DIM a[BOUNDS(a,0)+1] // add one to current size
a[0] = 5
Bye,
Gernot
#10398
ok. die karte+treiber passen. GLBasic macht alle Grafik und Texte mit 3D. Das ist viel schneller.
Er schreibt nix von "EndOnLine", also ist er abgestürzt. Seltsam.
Er schreibt eine Fehlermeldung beim Ausführen? Was sagt die genau?
Welche GLBasic Version? (menü: ?/Info)
Dann: Schick mit die .exe , die Du gemacht hast (HelloWorld.exe) und die .gbas und die .gbap per email.
#10399
Code (glbasic) Select
...
in$=INKEY$()
IF ASC(in$)ASC("9") THEN in$=""
...
;)

You ask if the ascii-value for the input character is in the range of "0" and "9" -> include "." if you want floating points as well.
#10400
User inkey$:
Code (glbasic) Select
// Test INKEY$ by replacing "INPUT" command

test$ = Inp$("What is the matrix?")
PRINT "test$ = " + test$,0,100
SHOWSCREEN
MOUSEWAIT

// ------------------------------------------------------------- //
// INPUT via INKEY$
// ------------------------------------------------------------- //
FUNCTION Inp$: name$
// Local name$
// Setup Starfield data
WHILE TRUE
IF KEY(14)
IF backspace=FALSE
name$=MID$(name$, 0, LEN(name$)-1) // Backspace
backspace=TRUE
ENDIF
ELSE
backspace=FALSE
last$ = in$
in$=INKEY$()
IF last$ <> in$ THEN name$=name$+in$
ENDIF
GOSUB ShowStarfield
PRINT name$, 0, 100
SHOWSCREEN
IF KEY(28) THEN RETURN name$ // Return pressed
WEND
ENDFUNCTION


// ------------------------------------------------------------- //
// -=#  SHOWSTARFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowStarfield:
LOCAL x,y,c,d,dt
dt=GETTIMERALL()
FOR x=0 TO 639 STEP 8
c=MOD(ABS(SIN(x))*x*5, 4)+1
y=MOD(MOD(x*13 + dt*c/200, 480), 480/8) * 480/8
d=c*64 -1
WHILE d>10
FILLRECT x,y, x+8, y+8, RGB(d/8,d,d/8)
d=d*.9
y=y-8
WEND
NEXT
ENDSUB // SHOWSTARFIELD
#10401
ufz! Keine Fehlermeldung? tipp mal in ein DOS-Fenster:
Code (glbasic) Select
TYPE %TEMP%\ErrorLog.txtund poste die Ausgabe hier.

Welche Version hat die IDE? Hast Du schon ein InternetUpdate versucht (Menü Web/InternetUpdate)


-Gernot
#10402
Code Snippets / JumpFrog
2005-Jul-02
Hmm... nachdem sich keiner traut, leg ich mal einen vor. Ein 2 Spieler "JumpFrog". Die Grafik ist etwas.. ähh.. ;)

Spieler 1: Space oder linke Maustaste
Spieler 2: Linke CTRL oder rechte Maustaste

Compiliert man unter 320x240 oder 640x480 - nicht höher :P

Es wundere sich keiner, dass er nix kapiert, so geht's mir nach einer Woche auch :D. Musste halt mal wieder schnell gehen.

Code (glbasic) Select
// --------------------------------- //
// Project: JumpFrog
// Start: Tuesday, May 10, 2005
// IDE Version: 2.50405

LIMITFPS -1

DIM frog_jump[2]
DIM frog_x[2] // offset to current platform - if jumping, real position
DIM frog_y[2] // on what platform
DIM frog_col[2]
frog_col[0] = RGB(0,255,0)
frog_col[1] = RGB(255,0,0)
GETSCREENSIZE screenx, screeny
MAX_PLATFORM = 50
JUMP_HEIGHT = screeny/8

frog_x[0] = 0.1
frog_x[1] = -0.1

WHILE TRUE
dtime = GETTIMERALL()*3
IF ( MOUSEAXIS(3) OR KEY(57) ) AND frog_jump[0] = 0 THEN JumpFrog(0, dtime)
IF ( MOUSEAXIS(4) OR KEY(29) ) AND frog_jump[1] = 0 THEN JumpFrog(1, dtime)
HandleFrog(0, dtime)
HandleFrog(1, dtime)
ShowAll(dtime)
WEND

// ------------------------------------------------------------- //
// -=#  SHOWALL  #=-
// ------------------------------------------------------------- //
FUNCTION ShowAll: dtime
LOCAL i, pos[], fx, nicecam
DIM pos[5]
GetPlatformPos(frog_y[0], dtime, pos[])

scale = 0.9 // dynamic camera speed
nicecam = -pos[1]*JUMP_HEIGHT + screeny*2/3
yoffset = yoffset*scale + (1-scale)*nicecam
FILLRECT 0,0, screenx, screeny, RGB(96,128,255)

// FROGGERS
FOR i=0 TO BOUNDS(frog_x[], 0)-1
GetPlatformPos(frog_y[i], dtime, pos[])
IF frog_jump[i]
fx = frog_x[i]
ELSE
fx = pos[0] + frog_x[i]
ENDIF

IF frog_jump[i] >= 0
dy = frog_jump[i]
ELSE
dy = SIN(90*frog_jump[i])
ENDIF

FILLRECT fx*screenx-16, (pos[1]+dy)*JUMP_HEIGHT+yoffset-32, _
fx*screenx   , (pos[1]+dy)*JUMP_HEIGHT+yoffset, frog_col[i]
DRAWLINE fx*screenx-14, (pos[1]+dy)*JUMP_HEIGHT+yoffset-30, _
fx*screenx -2, (pos[1]+dy)*JUMP_HEIGHT+yoffset-30, RGB(255,255,255)
NEXT

// PLATFORMS
FOR i = 0 TO MAX_PLATFORM
GetPlatformPos(i, dtime, pos[])
IF pos[4]=FALSE // not hidden
ALPHAMODE pos[3]
width = pos[2]*screenx/2
FILLRECT pos[0]*screenx-width, pos[1]*JUMP_HEIGHT+yoffset, _
pos[0]*screenx+width, pos[1]*JUMP_HEIGHT+yoffset + 0.2*JUMP_HEIGHT, _
RGB(200,96,0)
FILLRECT pos[0]*screenx-width, pos[1]*JUMP_HEIGHT+yoffset, _
pos[0]*screenx+width, pos[1]*JUMP_HEIGHT+yoffset + 2, _
RGB(0,128,0)
ALPHAMODE 0
PRINT INTEGER(MAX_PLATFORM-i+1), 0, pos[1]*JUMP_HEIGHT+yoffset
ENDIF // hidden
NEXT

IF bestlevel PRINT "Position: " + frog_y[0] + " Best: " + bestlevel, 0, 0
PRINT "GLBasic.com", GLOBAL screenx-220, GLOBAL screeny-30

dtime=GETTIMERALL()
IF dtime>lasttime+1000
fps = numframes/(dtime-lasttime)*1000
lasttime=dtime
numframes=0
ENDIF
numframes=numframes+1
PRINT "FPS:" +FORMAT$(0, 1, fps), 20, 25 // + dtime, 0,0

SHOWSCREEN
ENDSUB // SHOWALL


// ------------------------------------------------------------- //
// -=#  HANDLEFROG  #=-
// ------------------------------------------------------------- //
FUNCTION HandleFrog: num, dtime
// Diese Variablen sind als LOCAL definiert:
// num, dtime
LOCAL pos[]
DIM pos[5]
SELECT frog_jump[num]
CASE <0 // jumping
frog_jump[num] = frog_jump[num] - GETTIMER()/500
SetOnPlatform(num, dtime)
CASE >0 // falling
frog_jump[num] = frog_jump[num] + GETTIMER()/700
SetOnPlatform(num, dtime)
CASE 0 // standing
GetPlatformPos(frog_y[num], dtime, pos[])
IF pos[4] // toggling platform - is gone!
FallFrog(num, dtime)
ENDIF
ENDSELECT
ENDFUNCTION // HANDLEFROG

// ------------------------------------------------------------- //
// -=#  JUMPFROG  #=-
// Make frog jumping
// ------------------------------------------------------------- //
FUNCTION JumpFrog: num, dtime
LOCAL pos[]
DIM pos[5]
IF frog_jump[num] <> 0 THEN RETURN
GetPlatformPos(frog_y[num], dtime, pos[])
frog_jump[num] = -0.01
frog_x[num] = pos[0] + frog_x[num]
PLAYSOUND 0, (2*frog_x[num])-1, 1
ENDFUNCTION

// ------------------------------------------------------------- //
// -=#  FALLFROG  #=-
// Make frog falling
// ------------------------------------------------------------- //
FUNCTION FallFrog: num, dtime
LOCAL pos[]
DIM pos[5]
IF frog_jump[num] <> 0 THEN RETURN
GetPlatformPos(frog_y[num], dtime, pos[])
frog_jump[num] = 0.01
frog_x[num] = pos[0] + frog_x[num]
ENDFUNCTION

// ------------------------------------------------------------- //
// -=#  SETONPLATFORM  #=-
// Try to attach a frog to the next closest platform
// ------------------------------------------------------------- //
FUNCTION SetOnPlatform: num, dtime
LOCAL frogx
LOCAL pos[]
DIM pos[5]
IF ABS(frog_jump[num])>1
IF frog_jump[num] > 1 THEN frog_y[num]=frog_y[num]-1
IF frog_jump[num] <-1 THEN frog_y[num]=frog_y[num]+1
frog_jump[num] = 0
// check if you're on a platform now
GetPlatformPos(frog_y[num], dtime, pos[])
frogx = frog_x[num]
frog_x[num] = frog_x[num]-pos[0]
IF pos[4] OR (ABS(pos[0] - frogx) > pos[2]/2)
FallFrog(num, dtime)
ENDIF
ENDIF
ENDFUNCTION


FUNCTION PseudoRand: num
LOCAL ps_rnd, i
ps_rnd = 1247
FOR i=0 TO ABS(num+1)
// ps_rnd = qCOS(360*(ps_rnd+i))+qSIN(ps_rnd*i)*i
SELECT MOD(i, 4)
CASE 0; ps_rnd=ps_rnd+1027*i
CASE 1; ps_rnd=ps_rnd*21+MOD(i, ps_rnd)
CASE 2; ps_rnd=ps_rnd*i+13
CASE 3; ps_rnd=MOD(ps_rnd, i)
ENDSELECT
NEXT
RETURN ABS(INTEGER(ps_rnd))
ENDFUNCTION

// ------------------------------------------------------------- //
// -=#  GetPlatformPos  #=-
// pos[0] = x [0; 1] or -1000 if invisible
// pos[1] = y [0; n] 1 unit = 1 storey heigth
// pos[2] = width [0; 1]
// pos[3] = alphamode (for vanishing blocks)
// pos[4] = is hidden?
// ------------------------------------------------------------- //
FUNCTION GetPlatformPos: num, dtime, pos[]
// Diese Variablen sind als LOCAL definiert:
// num, dtime
LOCAL x
IF BOUNDS(pos[], 0) < 5 THEN DIM pos[5]

dtime = dtime * (5+num/MAX_PLATFORM)/40
pos[2] = 0.15 + (MAX_PLATFORM-num)/MAX_PLATFORM*0.30
pos[3] = 0
pos[4] = FALSE

SELECT MOD(PseudoRand(num),5) // MOD(num-1, 4)
CASE 0 // linear motion
x = MOD(dtime*(num+10)/MAX_PLATFORM, 1000)
IF x>500
x = (1000-x)/500
ELSE
x = x/500
ENDIF
CASE 1 // disapear in the center
x = MOD(dtime*num/MAX_PLATFORM, 1000)
IF x>700
pos[4]=TRUE
ENDIF
SELECT x
CASE <100
pos[3] = -x/100 + 0.001
CASE >600
pos[3] = -(700-x)/100 + 0.001
ENDSELECT
x = 0.5
CASE 2 // sin
x = (1+SIN(dtime*num/MAX_PLATFORM))/2
CASE 3 // whacky
x = ABS(COS(dtime*num/13/MAX_PLATFORM) + SIN(dtime*num/MAX_PLATFORM))/2
CASE 4 // sin + hide
x = MOD(dtime*num/MAX_PLATFORM, 1000)
IF x>700
pos[4] = TRUE
ENDIF
SELECT x
CASE <100
pos[3] = -x/100 + 0.001
CASE >600
pos[3] = -(700-x)/100 + 0.001
ENDSELECT
x = (1+SIN(0.5 * dtime*num/MAX_PLATFORM))/2
ENDSELECT

pos[0] = (1-pos[2]) * x + pos[2]/2
pos[1] = -num //*JUMP_HEIGHT
IF num = 0; pos[2]=1; pos[0]=0.5; pos[3]=0; pos[4]=FALSE; ENDIF
ENDFUNCTION // GETPLATFROMPOS
#10403
GLBasic - en / Jumpmarks
2005-Jun-22
I think when you look at the smalfont.bmp, that there's some space at the right side of the smal "o" letter. I've seen this problem shortly and I'm including a fix for the FontGenerator with the next update.

-Gernot
#10404
Yes, GLBasic does 3D with the new update. It's not optimized to the max, yet, but hey: It's 3D for the PocketPC! Muhahaha.

Greetz,
Gernot
#10405
...mit dem neuen Update! Noch nicht optimal, aber: GLBasic macht 3D auf dem PocketPC! Muhahaha.

-Gernot
#10406
Also, wenn Dein Level nur aus einer ddd (3ds) Datei besteht, brauchst Du keinen Level-Editor und kein Feld und nix.
Bei Wumbo hab ich aber das Spielfeld aus "Blöcken" zusammengebaut, wobei jeder Block ganz individuell im Raum stehen kann (XYZ und Drehung um Y). Das brauch ich, weil bewegliche Plattformen, Wasser und Süßigkeiten, extra Leben usw... irgendwo platziert werden müssen. Im 3D Raum eben am einfachsten durch XYZ statt in einem Feld:
Code (glbasic) Select
##++####
#++++++#
#####++#
########
Mein Level Editor ist dabei der GLBasic editor, weil ich zu faul war einen Editor zu schreiben - muss ich irgenwann mal machen.

Die Koordinaten der ddd(3ds) Datei bekommst Du nicht, aber Du kannst prüfen, ob Kugeln, Quader oder Linien Sie berühren. (X_COLLISIONxxx)

Hilft das?
Gruß,
Gernot
#10407
Quote from: Baggi1.
Zylinder - oder Polarkoordinaten ?
Benutz man in der 3D Welt Zylinderkoordinaten mit
x=rcos(phi)
z=rsin(phi)
y=y

oder
Polarkoordinaten mit
x=rsin(theta)cos(phi)
z=rsin(theta)sin(phi)
y=rcos(theta)
GLBasic nutzt Polarkoordinaten. D.h. wenn Du's in zylindrisch willst, musst Du mit x=r*cos(phi); y=r*sin(phi); y=y; arbeiten. Kugelkoordinaten analog.

Quote from: Baggi2.
In einem 2D Spiel besteht die Spieloberfläche oft aus "Kacheln"
also aus einem 2D Array. Damit kann man Positionen von Spielfiguren oder
Hindernissen überblicken, hat also die volle Kontrolle. Entwirft
man sich in der 3D Welt ein 3D Array mit allen Koordinaten - Infos über die Welt ?
Das hab ich bei den "TruckDriver" so gemacht weil:
- die Kollisionsabfrage einfacher ist
- die Level aus einer "2D" Textdatei geladen werden können

Bei Wumbo's Adventure hab ich mir Objekt-ID, X, Y, Z, Rot, gemerkt, weil:
- dadurch viel "freiere" Level möglich sind
- die Objekte nicht an ein Raster gezwungen werden
- "3D" einfacher geht, weil man den Y Wert angeben kann

Das muss man von Prjekt zu Projekt überlegen, was günstiger ist.

Quote from: Baggi3.
Bei einem 3D Ego Shooter befindet sich in der Mitte des Bildschirmes ein
2D Fadenkreuz. Wenn der Held einen Schuss aus seiner Waffe abfeuert, soll
der 3D Gegenstand in der Projektion des 2D Fadenkreuzes getroffen werden.
Gibt es in GLBasic die Möglichkeit abzufragen, welcher 3D Punkt auf welchen
2D Punkt auf dem Bildschirm abgebildet wird ?
Wenn das Fadenkreuz in der Mitte ist, dann hast Du Deine Position und Richtung ja bei X_CAMERA angegeben. Die Abfrage, ob ein Objekt dazwischen ist, kann man mit X_COLLISIONRAY machen. Das geht sehr schnell.

Quote from: Baggi4.
Gibt es ein Buch, welches sich mit solchen und ähnlichen Fragen
auseinandersetzt ?
Sorry, fällt mir keines ein - vielleicht weiß jemand ein gutes Buch?

Gruß,
Gernot
#10408
Yes. That's in the manual under "advanced techniques" or something like that.
Code (glbasic) Select
LOADSPRITE "red.bmp", 0
SPRITE 0,0,0
LOADSPRITE "blue.bmp", 0
SPRITE 0, 32,0
LOADSPRITE "", 0 // free memory
SHOWSCREEN; MOUSEWAIT
Greez,
Gernot
#10409
Für PocketPC 2002 und 2003, 2003SE:
http://www.glbasic.com/files/glbasic2.tsk

Hier noch einen Screenshot:




Hier die neue Version:



[attachment deleted by admin]
#10410
For PocketPC 2002 and 2003, 2003SE:
http://www.glbasic.com/files/glbasic2.tsk

Here's a screenshot: