BASIC

Author Topic: Wieder mal Types  (Read 3363 times)

Offline Worebu

  • Mr. Polyvector
  • ***
  • Posts: 169
  • Moin, Moin
    • View Profile
Wieder mal Types
« on: 2015-Feb-08 »
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.

PC: Intel I7 3770K, 32GB DDR3, GTX1060 6GB,  480GB SSD, 1x2TB, 1x1TB, 2x ext. 1TB USB3.0, 1x ext. 2TB USB3.0, W10 x64 Pro, WaKü

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4142
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Wieder mal Types
« Reply #1 on: 2015-Feb-08 »
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.

Offline Marmor

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 908
  • 96A285CC
    • View Profile
    • my youtube channel
Re: Wieder mal Types
« Reply #2 on: 2015-Feb-08 »
great ian , this will help a lot of user

Offline Worebu

  • Mr. Polyvector
  • ***
  • Posts: 169
  • Moin, Moin
    • View Profile
Re: Wieder mal Types
« Reply #3 on: 2015-Feb-08 »
Thanks very much Ian. That is what i need.
PC: Intel I7 3770K, 32GB DDR3, GTX1060 6GB,  480GB SSD, 1x2TB, 1x1TB, 2x ext. 1TB USB3.0, 1x ext. 2TB USB3.0, W10 x64 Pro, WaKü

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5009
  • O Rly?
    • View Profile
Re: Wieder mal Types
« Reply #4 on: 2015-Feb-08 »
Schön in einen Tutorial genannt/zitiert zu werden :)
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Worebu

  • Mr. Polyvector
  • ***
  • Posts: 169
  • Moin, Moin
    • View Profile
Re: Wieder mal Types
« Reply #5 on: 2015-Feb-08 »
Apropros Tut, läufts ?
« Last Edit: 2015-Feb-09 by Worebu »
PC: Intel I7 3770K, 32GB DDR3, GTX1060 6GB,  480GB SSD, 1x2TB, 1x1TB, 2x ext. 1TB USB3.0, 1x ext. 2TB USB3.0, W10 x64 Pro, WaKü

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5009
  • O Rly?
    • View Profile
Re: Wieder mal Types
« Reply #6 on: 2015-Feb-10 »
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 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Worebu

  • Mr. Polyvector
  • ***
  • Posts: 169
  • Moin, Moin
    • View Profile
Re: Wieder mal Types
« Reply #7 on: 2015-Feb-10 »
Schade das mit dem TUT, aber von deiner Hilfe werde ich gerne bei Zeiten Gebrauch machen.
PC: Intel I7 3770K, 32GB DDR3, GTX1060 6GB,  480GB SSD, 1x2TB, 1x1TB, 2x ext. 1TB USB3.0, 1x ext. 2TB USB3.0, W10 x64 Pro, WaKü

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4174
    • View Profile
    • Portfolio
Re: Wieder mal Types
« Reply #8 on: 2015-Feb-12 »
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!

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4142
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Wieder mal Types
« Reply #9 on: 2015-Feb-13 »
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.
« Last Edit: 2015-Feb-13 by Ian Price »
I came. I saw. I played.

Offline Worebu

  • Mr. Polyvector
  • ***
  • Posts: 169
  • Moin, Moin
    • View Profile
Re: Wieder mal Types
« Reply #10 on: 2015-Feb-13 »
Very cool.
PC: Intel I7 3770K, 32GB DDR3, GTX1060 6GB,  480GB SSD, 1x2TB, 1x1TB, 2x ext. 1TB USB3.0, 1x ext. 2TB USB3.0, W10 x64 Pro, WaKü