# data[].attributes.body
GP 1

# data[].attributes.body
GP 1a code

# data[].attributes.attachment_link.readable_text
using Microsoft.DirectX.Direct3D;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace p1a
{
    public partial class Form1 : Form
    {
        Microsoft.DirectX.Direct3D.Device device;
        public Form1()
        {
            InitializeComponent();
            InitDevice();

        }
        public void InitDevice()
        {
            PresentParameters pp = new PresentParameters();
            pp.Windowed = true;
            pp.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing,
            pp);
        }
        private void Render()
        {
            device.Clear(ClearFlags.Target, Color.Orange, 0, 1);
            device.Present();
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Render();
        }
    }
}

# data[].attributes.body
GP 1B txt

# data[].attributes.attachment_link.readable_text
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX; //OUR CODE
using Microsoft.DirectX.Direct3D; //OUR CODE

namespace pract1b
{
    public partial class Form1 : Form
    {
        Microsoft.DirectX.Direct3D.Device device;
        Microsoft.DirectX.Direct3D.Texture texture; 
        Microsoft.DirectX.Direct3D.Font font;
        public Form1()
        {
            InitializeComponent();
            InitDevice(); 
            InitFont(); 
            LoadTexture();
            this.Paint += new PaintEventHandler(Form1_Paint);
        }
        private void InitFont() 
        {
            System.Drawing.Font f = new System.Drawing.Font("Arial", 16f, FontStyle.Regular);
            font = new Microsoft.DirectX.Direct3D.Font(device, f);
        }

        private void LoadTexture() 
        {
            try
            {
                texture = TextureLoader.FromFile(device, "C:\\Users\\visha\\OneDrive\\Pictures\\wal2\\1920x1080-catan-vr-4k_1543621071.jpg", 900, 450, 1, 0,
                    Format.A8B8G8R8, Pool.Managed, Filter.Point, Filter.Point, Color.Transparent.ToArgb());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading texture: " + ex.Message);
            }
        }

        private void InitDevice() 
        {
            PresentParameters pp = new PresentParameters();
            pp.Windowed = true;
            pp.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Hardware, this,
                CreateFlags.SoftwareVertexProcessing, pp);
        }

        private void Render() 
        {
            device.Clear(ClearFlags.Target, Color.Cyan, 0, 1);
            device.BeginScene();
            using (Sprite s = new Sprite(device))
            {
                s.Begin(SpriteFlags.AlphaBlend);

                // Get the texture dimensions
                int textureWidth = texture.GetLevelDescription(0).Width;
                int textureHeight = texture.GetLevelDescription(0).Height;

                // Create a rectangle based on the texture dimensions
                Rectangle textureRect = new Rectangle(0, 0, textureWidth, textureHeight);

                // Fixed the Draw2D method call with a Rectangle
                s.Draw2D(texture,
                          new Rectangle(0, 0, device.Viewport.Width, device.Viewport.Height), // Destination rectangle
                          textureRect,
                          new Point(0, 0),
                          0f,
                          new Point(0, 0),
                          Color.White);
                font.DrawText(s, "GAME PROGRAMMING", new Point(0, 0), Color.Black);
                s.End();
            }
            device.EndScene();
            device.Present();
        }


        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Render(); 
        }
    }
}




# data[].attributes.body
GP 2a

# data[].attributes.attachment_link.readable_text
import pygame
pygame.init()
screen = pygame.display.set_mode((400,500))
done = False
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done=True
pygame.display.flip()

# data[].attributes.body
GP 2b

# data[].attributes.attachment_link.readable_text
import pygame
pygame.init()
white = (255,255,255)
height = 400
width = 400
display_surface = pygame.display.set_mode((height,width))
pygame.display.set_caption('Image')
image = pygame.image.load("D:\image.jpg")
while True:
    display_surface.fill(white)
    display_surface.blit(image,(0,0))
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            quit()
        pygame.display.update()
pygame.display.flip()

# data[].attributes.body
GP 2C

# data[].attributes.attachment_link.readable_text
import pygame
pygame.init()
screen=pygame.display.set_mode((400,300))
done = False
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
    pygame.draw.rect(screen,(0,125,255),pygame.Rect(30,90,60,110))
pygame.display.flip()

# data[].attributes.body
GP 2d

# data[].attributes.attachment_link.readable_text
import pygame
pygame.init()
pygame.display.set_caption('Keyboard events')
pygame.display.set_mode((400,400))
while True:
    event = pygame.event.wait()
    
    if event.type == pygame.QUIT:
        break
    if event.type in (pygame.KEYDOWN,pygame.KEYUP):
        key_name = pygame.key.name(event.key)
        key_name = key_name.upper()
        if event.type == pygame.KEYDOWN:
            print("{}key Pressed".format(key_name))
        elif event.type == pygame.KEYUP:
            print("{}key Released".format(key_name))

# data[].attributes.body
GP 5

# data[].attributes.body
GP 5 code

# data[].attributes.attachment_link.readable_text
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class scroller : MonoBehaviour
{
    public float speed = 0.5f;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        Vector2 offset = new Vector2(Time.time * speed, 0);
        Renderer renderer = GetComponent<Renderer>();

        if (renderer != null) { 
            renderer.material.mainTextureOffset = offset;
        }
    }
}

# data[].attributes.body
GP 6

# data[].attributes.body
GP 6 code

# data[].attributes.attachment_link.readable_text
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraShake : MonoBehaviour
{
    public float power = 0.7f;
    public float duration = 1.0f;
    public Transform camera;
    public float slowDownAmount = 1.0f;
    public bool shouldShake = false;

    Vector3 startPosition;
    float initialDuration;

    // Start is called before the first frame update
    void Start()
    {
        camera = Camera.main.transform;
        startPosition = camera.localPosition;
        initialDuration = duration;
    }

    // Update is called once per frame
    void Update()
    {
        if (shouldShake)
        {
            if (duration > 0)
            {
                camera.localPosition = startPosition + Random.insideUnitSphere * power;
                duration -= Time.deltaTime * slowDownAmount;
            }
            else
            {
                shouldShake = false;
                duration = initialDuration;
                camera.localPosition = startPosition;

            }
        }
    }
}

# data[].attributes.body
GP 7

# data[].attributes.body
GP 8

# data[].attributes.body
GP 9

# data[].attributes.body
GP 5,6,7,8 STEPS