MonoGame Tutorial 002 - Moving a Sprite

  Рет қаралды 20,062

Oyyou

Oyyou

Күн бұрын

Пікірлер: 29
@alanbal888
@alanbal888 6 жыл бұрын
Oyyou, I started back in 2013 (back in the good old XNA days) or so when I had a decent lenovo laptop with a GPU and that thing could fly...then it break and had a laptop that would start melting if I ran anything like visual studio. After all this years I got a job (at programming) and I could afford a new very well equiped PC and first thing I got installed was VS and Monogame, now I'll watch all your Monogame tutorials to pursue my game development dream!!! Thanks a lot Oyyou.
@henryh1620
@henryh1620 5 жыл бұрын
I am an aspiring dev, super young but I'd like to take the time to thank you so much for this channel. I've finally got the time to go through your videos!
@Oyyou
@Oyyou 5 жыл бұрын
Thanks, fren. I hope they help (:
@opelastramm
@opelastramm 8 жыл бұрын
Hey, I've been a subscriber since your XNA days! Some of your tutorials really got me on my feet as a junior game developer and I hope to find your MonoGame tutorials just as valuable. I'm currently working on a MonoGame project myself so some fresh tutorials would be neat :) Keep up the good work. Btw that's the first time I see your face
@Oyyou
@Oyyou 8 жыл бұрын
+opelastramm Thanks, man. I hope I can help you learn new things! (: I thought I'd show my face so you all knew I was as weird as you guys ;)
@mehwishbhatti6207
@mehwishbhatti6207 2 жыл бұрын
Bonjour everyone! I've got a question. Essentially I've drawn my sprite but my sprite goes over the edges of the screen and disappears. I've tried solving this myself using the monogame articles on the website but then the sprite is stopped before it even reaches the edge of the screen! Does anyone have a solution to this?
@xornedge8204
@xornedge8204 2 жыл бұрын
I think that means that you put collisions on the borders. From what I know, collision boxes can have custom shapes and sizes but the most basic form occupies a whole tile(whatever size may that be in your project). After that I am not too sure as I am trying to learn this stuff myself XD But maybe this points in a direction that reaches the conclusion for you.
@ugib8377
@ugib8377 5 ай бұрын
This is two years later, so I'm sure you've figured this out, but for anyone else in the future looking for the answer here it is. This is keeping in mind that the vector2 variable in your game tracks the top left most point of your texture. (This is also using my own 32x32 pixel texture I made, your asset may be different dimensions) Here is the code first. if(_position.X < 0) { _position.X = 0; } else if (_position.X + 32 > 800) { _position.X = 768; } if (_position.Y < 0) { _position.Y = 0; } else if (_position.Y + 32 > 480) { _position.Y = 448; } Because your X/Y are on the top left of your texture, the first If for each statement is easy. If your textures X dips below 0, set the texture X to 0. Same can be done with the Y. This simulates a "collision" with the edge of the game window on the top and left side. The Else If for the two statements is the same thing, just accounting for the width/height of your texture (32 pixels in my case) and the width/height of the game window. If the X + Width of the Texture goes beyond the 800 pixel width on the Right side, reset the X to 800 - 32. Same logic for the Y. This effectively locks your texture into the screen. We can put the X and Y detections on If/Else Ifs because with a smaller sprite like this, you will never need to detect collisions on both X sides at once. Same for Y.
@farazkhan-bk4ff
@farazkhan-bk4ff 7 жыл бұрын
Hy bro.. How we can create angle in Xna.. Am making a brick breaker game its almost done but facing a problem when ever ball hit to the bar it goes in -ve velocity i want to add angle how can i do tht?
@henryh1620
@henryh1620 6 жыл бұрын
Thanks for these
@pointless3k
@pointless3k 2 жыл бұрын
on a quest to fix something in my own game that I noticed recently. in the quest to look at basic examples of moving a sprite I see it here too. the sprite movement is a bit jittery it doesnt feel smooth. (regardless of samplerstate, vector2 as drawing pos or rectangle) and if I see it in something simple as this demo. is this just a monogame thing. am I losing my mind?
@Oyyou
@Oyyou 2 жыл бұрын
Just watched it, and it does seem jittery, doesn't it. It could be the recording. Or it could be because I'm using a fixed float rather than using the gameTime Are you using the gameTime in your game or..?
@pointless3k
@pointless3k 2 жыл бұрын
@@Oyyou yup! I've gotten pretty far in terms of engine architecture and then I started noticing it and couldn't unsee it. in my case, I want to do pixel perfect rendering and so I have to use ints (but behinds the scenes I use floats to allow for smaller increaments until it ticks over to next pixel). started digging around in my own source. and then started removing things until I was left with just an empty screen and the sprite and still seeing it. but yeah could the video rendering in this case and/or the fixed values with uneven update rate that would make sense. argh. next step I figure I'll make a new project to see if I can replicate it and then throw out the question on relevant forum. it's the tiniest of jitter, but now that I see it it feels like the whole world will see it haha. thanks for the fast answer :) didn't expect it on an old video cheers!
@Oyyou
@Oyyou 2 жыл бұрын
@@pointless3k interesting. Could your monitor refresh rate be affecting it? If you do find yourself coming to a dead end, the discord server is quite active, and a lot of the people in there tend to have answers for these sorts of things!
@egesaglam9500
@egesaglam9500 7 жыл бұрын
you are perfect dude
@godlyhax4172
@godlyhax4172 4 жыл бұрын
My sprite is leaving a trail of itself.
@Oyyou
@Oyyou 4 жыл бұрын
That's weird. Like @ 2:07, line 80. There is the "...Clear(...);". Do you still have that?
@godlyhax4172
@godlyhax4172 4 жыл бұрын
@@Oyyou oh lmao. i see what ur talking about. i accidentally deleted it
@sleepnaught
@sleepnaught 3 жыл бұрын
I just did this, spent an hour wondering what the f was going on lol. ughhh.
@llb5834
@llb5834 8 жыл бұрын
You will make video on Collision,hitbox ?
@Oyyou
@Oyyou 8 жыл бұрын
Ya god damn right I will! Should do it soon enough.
@llb5834
@llb5834 8 жыл бұрын
Monodevelopp = XNA ? (it look like)
@Oyyou
@Oyyou 8 жыл бұрын
Yes. MonoGame came about when Microsoft stop supporting XNA. It's open source, so you can view the code online. Which is nice :)
@magic874
@magic874 2 жыл бұрын
how can i change the speed its moving at?
@ugib8377
@ugib8377 5 ай бұрын
Instead of += 1, try += 2. Or you can create a int variable named "speed", and use it for all the calculations. int speed = 4; if (Keyboard.GetState().IsKeyDown(Keys.S)) { _position.Y += speed; } Which allows you to globally control the speed of the sprite, and maybe change it elsewhere in your code.
@magic874
@magic874 5 ай бұрын
@@ugib8377 hey thanks for the response I appreciate it very much however I’m no longer in college and we were tasked to make a game
@ugib8377
@ugib8377 5 ай бұрын
@@magic874 I put it there more for anyone looking in the future. Though I'm sure he explains this later in the series. Hope all is well, and good luck out there.
@magic874
@magic874 5 ай бұрын
@@ugib8377 you too kind sir!
@3dfynn427
@3dfynn427 6 жыл бұрын
666
MonoGame Tutorial 003 - Create Sprite Object
10:14
Oyyou
Рет қаралды 17 М.
MonoGame Tutorial 006 - Sprite Shooting Bullets
18:26
Oyyou
Рет қаралды 19 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 26 МЛН
Чистка воды совком от денег
00:32
FD Vasya
Рет қаралды 5 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 12 МЛН
Smart Sigma Kid #funny #sigma
00:33
CRAZY GREAPA
Рет қаралды 37 МЛН
I built my own 16-Bit CPU in Excel
15:45
Inkbox
Рет қаралды 1,6 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 750 М.
Making a Desktop App with a Game Library
28:57
Coding with Sphere
Рет қаралды 32 М.
Making My Own Programming Language and Coding a Game in It
10:19
AstroSam
Рет қаралды 1,3 МЛН
What does a Game Engine actually do?
16:45
Ellie Rasmussen
Рет қаралды 172 М.
MonoGame Tutorial 010 - 2-Player Pong Game!
26:25
Oyyou
Рет қаралды 12 М.
The Best Games Made with MonoGame [2021]
15:25
Ask Gamedev
Рет қаралды 76 М.
How are Redstone Computers even possible?
19:36
Ellie Rasmussen
Рет қаралды 358 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 26 МЛН