Visual Studio Graphics encoding problem.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
jedi18
Posts: 2
Joined: March 20th, 2019, 1:55 am

Visual Studio Graphics encoding problem.

Post by jedi18 » March 29th, 2019, 3:36 am

After finishing the beginner playlist I decided to have a go at creating a ship invaders style game before moving on to intermediate.

I'm trying to make the asteroids appear from the top. I've figured out how to do it but to make my job easier I created a python code
to convert the Draw function with the putpixel calls to include if conditions.

It all works well however when I copy the text into SpriteCodex.cpp file it shows me an error saying some characters are in unicode and I need to the encoding, which if I attempt to do ends up with intellisense not recognizing any of the variables. Could someone please help me with this issue?

Here's my python code :-

Code: Select all

converted = []

def add_if(n):
    converted.append("if(y - {} >= 0)".format(n))
    converted.append("{")

def ifinator(lin):
    last = -1
    for line in lin:
        index = line.find(" + y") - 1
        if int(line[index-1:index+1].strip()) != last:

            # end if condition
            if last!=-1:
                converted.append("}")

            add_if(int(line[index-1:index+1].strip()))
            converted.append(line)
            last = int(line[index-1:index+1].strip())
        else:
            converted.append(line)
    converted.append("}")

with open(r"C:\Users\targe\Downloads\Chili DirectX Framework\PutPixelImages\asteroid0.txt", "r") as f:
    lines = f.readlines()
    ifinator(lines)

with open(r"C:\Users\targe\Downloads\Chili DirectX Framework\PutPixelImages\asteroid0_converted.txt", "w") as f:
    f.writelines(converted)

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

Re: Visual Studio Graphics encoding problem.

Post by albinopapa » March 29th, 2019, 8:12 am

I recently ran across something similar, same error message, different cause. I copied some html formatted text from Chrome and pasted it into the project I was working on as a comment. When I tried to save the document I got that message and in order to save it I had to convert it. My guess, your python script is writing characters that are not ASCII, but instead Unicode characters to the Graphics.cpp file.

When intellisense stops working, I usually restart VS or restart the whole computer, whichever works first.
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

jedi18
Posts: 2
Joined: March 20th, 2019, 1:55 am

Re: Visual Studio Graphics encoding problem.

Post by jedi18 » March 30th, 2019, 1:38 am

Thanks a lot!

Yeah that was indeed the issue, for some reason one line had some weird symbols in unicode that could not be converted to ascii.
Anyway I got the python script fixed to write in ascii instead (and delete the weird symbols as well) and it works as intended now.

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

Re: Visual Studio Graphics encoding problem.

Post by albinopapa » March 30th, 2019, 3:13 am

Good deal.
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

Post Reply