Wieder mal Types

Previous topic - Next topic

Worebu

Hallo Leute,
wollte mir mal Types ein wenig näherbringen und habe dazu ein kleines Projekt gefunden. Allerdings bekomme ich es nicht zum laufen
um mit den Werten zu spielen und mir die Auswirkung anzusschauen. Kann mir jemand helfen un dsagen wo der Fehler liegt?.

Das Projekt ist das hier: http://www.commodore-welt.de/tutorial/tutorial.pdf .

Dank im voraus.

Intel I5 9600 - RTX 4070, WaKü, 32GB RAM, 1x 512gb + 1x 1Gb NVRAM,  1x4TB + 1x1TB HD

Ian Price

Here's an example that I've just put together.

I've commented in the code what each part does. Hopefully by changing values you can understand a bit more.

I came. I saw. I played.

Marmor

great ian , this will help a lot of user

Worebu

Thanks very much Ian. That is what i need.
Intel I5 9600 - RTX 4070, WaKü, 32GB RAM, 1x 512gb + 1x 1Gb NVRAM,  1x4TB + 1x1TB HD

Schranz0r

Schön in einen Tutorial genannt/zitiert zu werden :)
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

Worebu

#5
Apropros Tut, läufts ?
Intel I5 9600 - RTX 4070, WaKü, 32GB RAM, 1x 512gb + 1x 1Gb NVRAM,  1x4TB + 1x1TB HD

Schranz0r

Ne aktuell andere Sachen um die Ohren.
Wenn du aber ein Problem hast, helfe ich natürlich gerne.
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

Worebu

Schade das mit dem TUT, aber von deiner Hilfe werde ich gerne bei Zeiten Gebrauch machen.
Intel I5 9600 - RTX 4070, WaKü, 32GB RAM, 1x 512gb + 1x 1Gb NVRAM,  1x4TB + 1x1TB HD

erico

Tried your shooter Ian!
Quite raiden!

I´m keeping it, I have been afraid of functions and types for quite a while.
Your example game is montruously clear to get to the point of how to use both.

Thanks!

Ian Price

#9
Cheers.

It's just a simple thing, but can hopefully lead to a better understanding and a cleaner method of working. Functions are just small portions of code that can do something, then hand back control to the main loop.

You could easily enhance that "game" by having the rocks move down the screen (at different speeds etc.) For that you could add a "speed" variable to the rock TYPE so that each rock moves at a constant but different speed, creating a type of parallax.

Eg

Code (glbasic) Select

TYPE Trock
x
y
speed
ENDTYPE


Then adding -

Code (glbasic) Select

FUNCTION create_rock:
...
...
r.speed=RND(3)+1
...
DIMPUSH ro[],r
ENDFUNCTION


and adding the y co-ordinate of each rock

Code (glbasic) Select

FUNCTION render_rock:
...
...
INC r.y, r.speed

// Respawn rock if it goes off the bottom of the screen
IF r.y>480
  create_rock()
DELETE r
ENDIF
...
...
ENDFUNCTION


You could build on those ideas to mkae the rocks bigger or smaller (add a "size" variable to the TYPE), add aliens, power-ups etc. Using the bullet/rock collision code you could make rocks collide with the ship etc. etc.

It's a small start that can lead to bigger and more exciting games.
I came. I saw. I played.

Worebu

Intel I5 9600 - RTX 4070, WaKü, 32GB RAM, 1x 512gb + 1x 1Gb NVRAM,  1x4TB + 1x1TB HD