Author Topic: New Game  (Read 5594 times)

0 Members and 1 Guest are viewing this topic.

Offline CoderVSB12

  • Newbie
  • Posts: 5
    • View Profile
New Game
« on: September 10, 2020, 04:56:05 pm »
So, i'm planning to make my first public game ever since 2 years ago, but i had some serious dificulties like procrastination in general.
Today, seeing the popularity of games like Fall Guys, i decided to finally start working on my project. It's about a bird that have to jump meteors while he's being chased by a round dinosaur spaceship, and everything in 2.5D; the bird is in its front view, and the meteors shrink down as they get far away, being sucked by the spaceship.
But there are some issues on my first prototype tho. Check my code and see if you can find it for me.

Code: QB64: [Select]
  1.  
  2. TYPE Birb
  3.     X AS INTEGER
  4.     Y AS INTEGER
  5.     Z AS INTEGER
  6.     Pic AS LONG
  7.     W AS INTEGER
  8.     H AS INTEGER
  9.     JumpSpeed AS INTEGER
  10.     JumpState AS INTEGER
  11.  
  12. TYPE Meteor
  13.     X AS INTEGER
  14.     Y AS INTEGER
  15.     Z AS INTEGER
  16.     Pic AS LONG
  17.     W AS INTEGER
  18.     H AS INTEGER
  19.     SpawnTime AS INTEGER
  20.  
  21. TYPE WindowBoi
  22.     W AS INTEGER
  23.     H AS INTEGER
  24.  
  25. DIM SHARED Birby AS Birb
  26. DIM SHARED Steroids AS Meteor
  27. DIM SHARED Wendow AS WindowBoi
  28.  
  29. Wendow.W = 1280
  30. Wendow.H = 720
  31. Birby.Pic = _LOADIMAGE("F&S_proto_sources\birby")
  32. Birby.W = 66
  33. Birby.H = 108
  34. Birby.X = (Wendow.W / 2) - (Birby.W / 2) - 1
  35. Birby.Y = (Wendow.H / 2) - (Birby.H / 2) + 1
  36. Steroids.Pic = _LOADIMAGE("F&S_proto_sources\meteor")
  37. Steroids.X = INT(RND * 1250) + 30
  38. Steroids.Y = INT(RND * 690) + 30
  39. Steroids.SpawnTime = 10
  40.  
  41. SCREEN _NEWIMAGE(1280, 720, 32)
  42.  
  43.     _LIMIT 100
  44.     PCOPY _DISPLAY, 1
  45.     SpawnMeteors
  46.     _DISPLAY
  47.     PCOPY 1, _DISPLAY
  48.  
  49. SUB SpawnMeteors
  50.     FOR i = 1 TO 20 STEP Steroids.SpawnTime
  51.         _PUTIMAGE (Steroids.X, Steroids.Y), Steroids.Pic
  52.     NEXT
  53.  
  54.  
« Last Edit: September 10, 2020, 05:12:59 pm by CoderVSB12 »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New Game
« Reply #1 on: September 10, 2020, 05:31:20 pm »
Welcome @CoderVSB12

For starters some images would help :)

If you can attach everything needed in a handy zip package it makes it easier for others to check out your stuff.
« Last Edit: September 10, 2020, 05:33:06 pm by bplus »

Offline CoderVSB12

  • Newbie
  • Posts: 5
    • View Profile
Re: New Game
« Reply #2 on: September 10, 2020, 05:53:59 pm »
I do have some concept drawings...

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New Game
« Reply #3 on: September 10, 2020, 06:45:57 pm »
@CoderVSB12
Why do you put two times the same image in the same place of the screen?
here the syntax of _PUTIMAGE that is quite different from PUT of Qbasic
http://www.qb64.org/wiki/PUTIMAGE

so with this code
Code: QB64: [Select]
  1. SUB SpawnMeteors
  2.     FOR i = 1 TO 20 STEP Steroids.SpawnTime  ' here Steroids.SpawnTime = 10 so i = 1 and then 11 and then again 21
  3.         _PUTIMAGE (Steroids.X, Steroids.Y), Steroids.Pic
  4.     NEXT
you're doing this
_PUTIMAGE (DestinationX, DestinationY), SourceHandle&
... so change your code for your goal!



Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New Game
« Reply #4 on: September 10, 2020, 08:08:02 pm »
Maybe this will help:
Code: QB64: [Select]
  1. _TITLE "Spawn" 'b+ mod 2020-09-10
  2. CONST angle = _PI(3 / 4)
  3. TYPE Meteor
  4.     X AS INTEGER
  5.     Y AS INTEGER
  6.     dx AS SINGLE
  7.     dy AS SINGLE
  8.  
  9. SCREEN _NEWIMAGE(1200, 720, 32)
  10. _DELAY .25 'allow screen to load
  11.  
  12. M& = _LOADIMAGE("meteor.png")
  13. 'FOR i = 0 TO 80            '           yucko
  14. '    _CLEARCOLOR _RGB32(i), M&
  15. '    _CLEARCOLOR _RGB32(i, 0, 0), M&
  16. '    _CLEARCOLOR _RGB32(0, i, 0), M&
  17. '    _CLEARCOLOR _RGB32(0, 0, i), M&
  18. '    _CLEARCOLOR _RGB32(i, i, 0), M&
  19. '    _CLEARCOLOR _RGB32(0, i, i), M&
  20. '    _CLEARCOLOR _RGB32(i, 0, i), M&
  21. 'NEXT
  22.  
  23. 'try filter
  24. newM& = _NEWIMAGE(_WIDTH(M&), _HEIGHT(M&), 32)
  25. _DEST newM&
  26. FOR y = 0 TO _HEIGHT(M&)
  27.     FOR x = 0 TO _WIDTH(M&)
  28.         p = POINT(x, y)
  29.         pr = _RED32(p)
  30.         pg = _GREEN32(p)
  31.         pb = _BLUE32(p)
  32.         IF pr > 50 AND pg > 50 AND pb > 50 THEN PSET (x, y), p ELSE PSET (x, y), &H00000000
  33.     NEXT
  34.  
  35. DIM SHARED spawn(1 TO 100) AS Meteor
  36. FOR i = 1 TO 100
  37.     SpawnMeteors (i)
  38.  
  39.     CLS
  40.     FOR i = 1 TO 100
  41.         spawn(i).X = spawn(i).X + spawn(i).dx
  42.         spawn(i).Y = spawn(i).Y + spawn(i).dy
  43.         IF spawn(i).X < -100 OR spawn(i).Y > _HEIGHT + 50 THEN SpawnMeteors i
  44.         _PUTIMAGE (spawn(i).X, spawn(i).Y)-STEP(_WIDTH(newM&), _HEIGHT(newM&)), newM&, 0
  45.     NEXT
  46.     _DISPLAY
  47.     _LIMIT 60
  48. LOOP UNTIL _KEYDOWN(27) 'escape
  49.  
  50. SUB SpawnMeteors (i)
  51.     spawn(i).X = _WIDTH + 1000 * RND
  52.     spawn(i).Y = -1000 * RND
  53.     spawn(i).dx = (RND * 15 + 5) * COS(angle)
  54.     spawn(i).dy = (RND * 15 + 5) * SIN(angle)
  55.  
  56.  

  [ You are not allowed to view this attachment ]  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New Game
« Reply #5 on: September 11, 2020, 11:25:01 am »
Spawn 2 variation 1, has much better 3D effect and all I did was add a mag = magnification property to the Meteor Type and then adjust speed according to magnification. You might consider mag a Z axis but this is 2.5 D stuff.

https://www.qb64.org/forum/index.php?topic=3009.msg122648#msg122648

Offline CoderVSB12

  • Newbie
  • Posts: 5
    • View Profile
Re: New Game
« Reply #6 on: September 11, 2020, 12:39:07 pm »
That's pretty good, but its not what i intended it to be; the meteors need to go directly from behind the camera, and not falling from the top.
« Last Edit: September 11, 2020, 12:41:15 pm by CoderVSB12 »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New Game
« Reply #7 on: September 11, 2020, 02:20:28 pm »
That's pretty good, but its not what i intended it to be; the meteors need to go directly from behind the camera, and not falling from the top.

Yeah, just giving you some example code to help you realize your conceptions. :)

Meanwhile I discover a great way to filter an image and turn it into a sprite! yahoo!
« Last Edit: September 11, 2020, 02:22:26 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New Game
« Reply #8 on: September 12, 2020, 06:22:23 pm »
@bplus
very good and interesting the animation! (Can you find a meteor with less pen(tr)is in it? The animation is too good but it can appear like a rain of....)

@CoderVSB12
do you say me if the movement of asteroid goes from behind the camera to the centre of screen ? Or viceversa?
to be clearer  follow this link https://www.youtube.com/watch?v=agEQ7YIYk0A and watch at 1.20 for some seconds... You want a movement like the shoots of fire of Blaster or in the opposite direction like the planets ?
Programming isn't difficult, only it's  consuming time and coffee

Offline CoderVSB12

  • Newbie
  • Posts: 5
    • View Profile
Re: New Game
« Reply #9 on: September 12, 2020, 07:22:52 pm »
This game represents the exact perspective i want. The meteors move pretty much like the shoots of fire, but at random positions.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New Game
« Reply #10 on: September 13, 2020, 06:26:10 am »
1.
well in this case you must use the Z axis to convert a 3D Dimension to a Sizes' Dimension... just nearer = larger and farer = smaller.
The second example of Bplus cover just this theme about Z axis for the third dimension. You'll keep X and Y but change Size by Z axis...
if movement is linear to infinite far or vice versa for the objects that run toward the camera.
The same ideas with different tecniques are developed in this thread https://www.qb64.org/forum/index.php?topic=1146.msg103690#msg103690 using the great p5js.bas (the porting to QB64 of P5JS used also by The code train programmer) here you can find it https://www.qb64.org/forum/index.php?topic=1146.msg103690#msg103690 and if you like its performance you can use for graphic effects.

2. back to your original code you must add before SpawnMeteors a SUB MoveMeteors in which you use the Z axis and MAP of P5js.bas to change the size/dimension of meteor OR calculate  the new size/dimension of meteor manually by an your function like Bplus had done!
Good Programming
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New Game
« Reply #11 on: September 13, 2020, 06:38:39 am »
Adjournment
here Bplus has made his engine to 3D  movement from infinite to back the camera. You must only invert the direction of movement or waiting that Bplus done it for you.
https://www.qb64.org/forum/index.php?topic=3009.msg122706#msg122706
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: New Game
« Reply #12 on: September 13, 2020, 08:11:48 pm »
Now I have done it ....https://www.qb64.org/forum/index.php?topic=3009.msg122736#msg122736
use it at your custom goal. And Thanks to Bplus to post his code.
Programming isn't difficult, only it's  consuming time and coffee

Offline CoderVSB12

  • Newbie
  • Posts: 5
    • View Profile
Re: New Game
« Reply #13 on: September 13, 2020, 09:02:50 pm »
Thanks very much! Now i just need them to vanish towards the center of the screen, but you might want to wait as i try to do it by myself before i ask you for help, ok?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: New Game
« Reply #14 on: September 13, 2020, 09:39:49 pm »
Thanks very much! Now i just need them to vanish towards the center of the screen, but you might want to wait as i try to do it by myself before i ask you for help, ok?

I was hoping for this, just to get you started.