Shoot Em Up - Video

Previous topic - Next topic

Shogun

wie dumm, na klar, die Grafiken. Garnicht drann gedacht.

Schranz0r

Aller anfang ist schwer Shogun ist kein Beinbruch, passiert uns allen mal so leichtsinnsfehler, Jaaaaaa auch den lieben Herrn Gernot ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Antidote

ohne Bilder wird es schwer... ;)
PC Core2Duo e4300, 2GBRam, Geforce 8800GT-1gb, XPsp3
GP2x, Wii, XBox360, Wiz, psp, ps3 usw.

Hotshot

Very good Tutorials :nw:

bigsofty

Just be aware that the language has changes a lot in the 5 years since these videos were created.  ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

aroldo

Hello GLB community!

I decided to do some improvements in this great tutorial made by Gernot (Kitty Hello), so I did changes to it as follows:

  • Added Sound
  • Images

The Blaster GLB project,  image and sound files are attached in the zip file below.
Just unzip to the directory of your choice.

Enjoy!!!

Here is the code.
Code (glbasic) Select
// --------------------------------- //
// Project: Blaster
// Start: Thursday, April 05, 2007
// IDE Version: 4.145

// A SHOT type. It's just the position in this sample
// Ein Schuss-TYPE. Hier ist nur die Position von Bedeutung
TYPE SHOT
x
y
ENDTYPE

TYPE FOE
x
y=10
speed=3
amour=4
ENDTYPE

TYPE BOOM
x
y
time
ENDTYPE
// Variables

// a SHOT for adding new ones later
// ein SHOT um später neue hinzuzufügen
LOCAL newshot AS SHOT
LOCAL newbug  AS FOE
LOCAL player_x, player_y

// Image Sizes
LOCAL player_w, player_h
LOCAL lazer_w, lazer_h
LOCAL shot_w, shot_h
LOCAL bug_w, bug_h
LOCAL boom_w, boom_h


LOCAL delay
LOCAL time, nextbug, didhit

LOCAL screenW, screenH
// Audio
GLOBAL vol = 1.0 // 0.0 low - 1.0 loud
GLOBAL pan = 0 // -1.0 left, 0 center, 1.0 right

// The SHOTs array. Here the shots get inserted
// das SHOTs Feld. Hier kommen die Schüsse rein
LOCAL shots[] AS SHOT
LOCAL bugs[] AS FOE
LOCAL poof[] AS BOOM

//Sound Files
LOADSOUND "Media/sounds/blow.wav", 0, 4 // shot
LOADSOUND "Media/sounds/explosion.wav", 1, 2 // explosion

// Images
LOADSPRITE "Media/images/lazer.png", 0
LOADSPRITE "Media/images/shot.png", 1
LOADSPRITE "Media/images/bug.png",  2
LOADSPRITE "Media/images/boom.png", 3

GETSPRITESIZE 0, lazer_w, lazer_h // lazer
GETSPRITESIZE 1, shot_w, shot_h // shot
GETSPRITESIZE 2, bug_w, bug_h // bug
GETSPRITESIZE 3, boom_w, boom_h // boom


GETSCREENSIZE screenW, screenH

// Set player X and Y position on the screen
player_x = screenW/2
player_y = screenH/3

WHILE TRUE
// Player Movement
// Spieler Bewegung
INC player_x, MOUSEAXIS(0)
// Limit to borders
// Auf den Rand begrenzen
player_x=MAX(MIN(player_x,screenW),0)

// Space bar and some time since last shot?
// Leertaste und etwas Zeit seit letztem Schuss vergangen?
IF MOUSEAXIS(3) AND delay<GETTIMERALL() // Prepare a shot
// Schuss vorbereiten
newshot.x = player_x+lazer_w/2-shot_w/2 // center shot on the cannon
newshot.y = player_y
// And stuff into the array
// Und in's Feld reinpacken
DIMPUSH shots[], newshot

play(0) // Play shooting sound!

// Get a time when the next shot can be fired
// Zeit festlegen, wann der nächste Schuss geladen ist
delay = GETTIMERALL() + 100
ENDIF


time = GETTIMERALL()
IF time>nextbug
nextbug = time + 500
LOCAL b AS FOE
DIMPUSH bugs[], b
ENDIF

FOREACH bug IN bugs[]
INC bug.x, bug.speed
IF bug.x<0 OR bug.x>screenW
INC bug.y, 32
bug.speed = -bug.speed
ENDIF
didhit=FALSE
FOREACH pop IN shots[]
IF BOXCOLL(pop.x, pop.y, 8,8, bug.x, bug.y, 32,32)
didhit=TRUE

play(1) // Play explosion sound

DELETE pop // continue to the end of the FOREACH loop
ENDIF
NEXT
IF didhit
LOCAL p AS BOOM
p.x = bug.x
p.y = bug.y-boom_h/2+bug_h/2
p.time = time
DIMPUSH poof[], p
DELETE bug
ENDIF
DRAWSPRITE 2, bug.x, bug.y // DRAW the Bug
NEXT


FOREACH p IN poof[]
LOCAL pos = (time - p.time) / 1000 // 0 ... 1
IF pos > 1 THEN DELETE p
ALPHAMODE 1-pos
// ******************************************************************

// IF you prefer the rotation effect coment DRAWSPRITE line
// and  uncomment the ROTOZOOMSPRITE line below.

// ROTOZOOMSPRITE 3, p.x, p.y, pos*1000, 1+pos*3 // DRAW Explosion
DRAWSPRITE 3, p.x,p.y // DRAW Explosion


// ******************************************************************
NEXT
ALPHAMODE 0



// Loop through all shots
// Durch alle Schüsse laufen
FOREACH pop IN shots[]
// Move shot up
// Schuss hoch bewegen
DEC pop.y, 5
// If shot reaches upper screen, remove it and continue
// Wenn Schuss am oberen Rand, dann entfernen und continue
IF pop.y<0 THEN DELETE pop

// Draw the shot
// Schuss zeichnen

DRAWSPRITE 1, pop.x, pop.y // DRAW the shot
NEXT

// Draw "player"
// "Spieler" zeichnen
DRAWSPRITE 0, player_x, player_y

SHOWSCREEN
WEND
// ------------------------------------------------------------- //
// ---  PLAY  ---
// ------------------------------------------------------------- //
FUNCTION play: ch
PLAYSOUND (ch, pan, vol) // channel, pan, vol
ENDFUNCTION // PLAY



[attachment deleted by admin]
[a http://apd-games.com/][img http://apd-games.com/images/APDGames135.png][/a]
MacBook Pro OS X El Capitan
XCode Version 7
iPhone 6 running  iOS 9
iPad Mini running  iOS 7.1
Galaxy S5
Dell Latitude Windows 8 Enterprise
Palm Pre, Palm Pre2