Chili, maybe god, you, can you lend me some knowledge.

The Partridge Family were neither partridges nor a family. Discuss.
Denial Newell
Posts: 2
Joined: August 2nd, 2016, 1:29 pm

Chili, maybe god, you, can you lend me some knowledge.

Post by Denial Newell » August 2nd, 2016, 3:50 pm

Conundrum:(C++ Beginner Tutorial 2/homework/LazinessOrEfficiency)

I wrote expression methods for the find and replace feature; trying to be lazy moving all the pixel's x,y values at once. (Spent an hour researching because I believed a way had to exist and might be handy when/if editing repetitive string datasets. It might not be justified in this scenario, but still applicable, AND I JUST WANTED TO LEARN IT GET OFF MY CASE!)

e.g:

gfx.PutPixel(395,300,255,255,255);
gfx.PutPixel(396,300,255,255,255);

Find ((.*?),(.*?),
Replace ($1+300,$2+200,

Result:

gfx.PutPixel(395+300,300+200,255,255,255);
gfx.PutPixel(396+300,300+200,255,255,255);

Gets the job done homework complete. I could just leave it there and call it a day. But it made the strings longer, complex and requires a different expression method to alter the position again. Grave = Dug.

To locate and modify new string format

Find \((.*?)\+300,(.*?)\+200,
Replace ($1,$2,

Now, here's the question. Is there an expression method to make the calculation happen when it replaces the string to move the reticle, instead of my original method where it creates a calculation to move the reticle?

Because god knows my tiny little brain could barely comprehend how to avoid it. It would be nice if that method exists.

Otherwise, I will reset the reticle values to the top left hand side but so it keeps it's shape and use the calculation without going into negative values and remain sane.

Here is who taught me to be lazy. https://msdn.microsoft.com/en-us/library/2k3te2cs.aspx

Also I'm trash tier beginner if I confused you just delete me off the face of the internet fam. I hope I'm using the wrong names for things.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by chili » August 3rd, 2016, 12:33 am

Oh shit son, you've gone down the regex hole. I fuckin love that shit btw. I gotta catch the train to work now, answer this stuff in a bit ;)
Chili

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by chili » August 3rd, 2016, 1:14 am

If I grok you correctly, you wanna do something like this this:

Code: Select all

PutPixel(301,200,255,255,255) -> PutPixel( 501,350,255,255,255 )
instead of

Code: Select all

PutPixel(301,200,255,255,255) -> PutPixel(301 + 200,200 + 150,255,255,255)
Unfortunately, regex does not deal with values like that, only simple text replacement, so this is just not possible my friend. I think your first method works completely fine though. Whenever you wanna change the position, you'd just do something like this: http://regexr.com/3du9p

Regex can be a godsend when refactoring code. Also, C++ has a RegularExpression class you can use in your actual programs to process text. I might cover VS regex in a tutorial at some point, I had meant to in the HUGS series, but then I got distracted, probably by something shiny.

Also, I like your style bro, welcome to the forums ; )
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by albinopapa » August 3rd, 2016, 4:11 am

adabo tried teaching me RegEx, "I didn't have time for that". Shit is hard to understand until you get it.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Denial Newell
Posts: 2
Joined: August 2nd, 2016, 1:29 pm

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by Denial Newell » August 3rd, 2016, 5:10 am

Thank you for the speedy quick fast response and new method Chili. I look forward to leeching more knowledge from you as your new series progresses my dude. And albinopapa, I believe the only reason I learnt it quickly, is because I understood how it should work it before I knew it existed.

PutPixel255
Posts: 363
Joined: March 12th, 2013, 6:06 am
Location: "Keep Louisville Weird"

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by PutPixel255 » August 4th, 2016, 5:42 pm

Chili wrote:I gotta catch the train to work now
I hope it's not a holiday :P

OK I didn't do the quote thing right, oh well.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by albinopapa » August 4th, 2016, 9:39 pm

That sounds familiar, did chili say something about catching the train to work and not realizing it was a holiday in one of his videos?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by chili » August 5th, 2016, 1:59 am

Well, I don't know for sure whether it came up in a video, but that is a thing that has happened, so it is entirely possible :p
Chili

freebattie
Posts: 197
Joined: August 4th, 2016, 10:05 am

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by freebattie » August 5th, 2016, 5:15 am

Yeah you did mentioned it in the old video :) think i saw it in beginner video 6.

User avatar
ScOrP!On
Posts: 5
Joined: July 30th, 2016, 7:47 pm

Re: Chili, maybe god, you, can you lend me some knowledge.

Post by ScOrP!On » August 5th, 2016, 9:28 pm

the way i did the solution is by making a function in the Game.h window where it says user functions
and slapped this bitch here

Code: Select all

	void cursor(int x , int y) {
     
		gfx.PutPixel(5 + x, 1 + y, 0, 0, 255);
		gfx.PutPixel(5 + x, 2 + y, 0, 0, 255);
		gfx.PutPixel(5 + x, 3 + y, 0, 0, 255);
		gfx.PutPixel(5 + x, 7 + y, 0, 0, 255);
		gfx.PutPixel(5 + x, 8 + y, 0, 0, 255);
		gfx.PutPixel(5 + x, 9 + y, 0, 0, 255);
		gfx.PutPixel(1 + x, 5 + y, 0, 0, 255);
		gfx.PutPixel(2 + x, 5 + y, 0, 0, 255);
		gfx.PutPixel(3 + x, 5 + y, 0, 0, 255);
		gfx.PutPixel(7 + x, 5 + y, 0, 0, 255);
		gfx.PutPixel(8 + x, 5 + y, 0, 0, 255);
		gfx.PutPixel(9 + x, 5 + y, 0, 0, 255);
	
	
	}
this will place the reticule in the top left corner , then u slap this function call in the Game.cpp window , under compose frame .

Code: Select all

Game::cursor(0,0);
instead of "0" , u can change the number (cant be negative) so that u can move the reticule all over the place , "cursor" is the name i gave it , u can call it whatever u want .

now if i can get the kbd.Is.Pressed bullshit to work !! (chili where u at O.o) , i would make shit happen .
Last edited by ScOrP!On on August 6th, 2016, 8:13 am, edited 1 time in total.

Post Reply