Hello,
I am trying to start writing own modes. I am used to program shell scripts, and I can mostly understand and sometimes modify Perl, Java, Groovy, or even C++ code. But I don’t have any Python experience until now.
So I tried a small example: let a line move from left to right. The color and the position are changed by the same variable. That works fine with this script:
-------------snip------------
import os
import pygame
import math
count1 = 0
def setup(screen, etc):
pass
def draw(screen, etc):
global count1
if count1 > 254 :
count1 = 0
count1 = int(count1 + 1)
color = count1,0,0
xpos = int(count1*5)
thick = 100
pygame.draw.line(screen, color, [xpos, 1], [xpos, 720], thick)
-------------snip------------
Now I wanted to move forward and backward. I use this code:
-------------snip------------
import os
import pygame
import math
count1 = 0
direction = 0
def setup(screen, etc):
pass
def draw(screen, etc):
global count1
global direction
if count1 > 254 :
direction = 1
if count1 < 1 :
direction = 0
if direction = 0 :
count1 = int(count1 + 1)
if direction = 1 :
count1 = int(count1 - 1)
color = count1,0,0
xpos = int(count1*5)
thick = 100
pygame.draw.line(screen, color, [xpos, 1], [xpos, 720], thick)
-------------snip------------
But this time the mode won’t load at all.
What am I doing wrong here?
Any help is appreciated.